Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite scrolling for files app #7167

Merged
merged 14 commits into from
Apr 28, 2014
Merged

Conversation

PVince81
Copy link
Contributor

Adds in-memory infinite scroll: the whole files list is loaded into a JS array but only the next 20 table rows are rendered, and then the next 20, etc when scrolling.

@DeepDiver1975
Copy link
Member

@PVince81 What is your plan regarding the share information for the 20 loaded files?

From my point of view any share information should be delivered together with the file information.
This will reduce the number of ajax calls - because as of today share information for the complete folder is loaded in an extra call.

an example JSON response could look like this:

[
   {
      "fileId" : 6967,
      "shares" : [
         {
            "type" : "files",
            "shareType" : 5,
            "permission" : 1,
            "shareId" : 241,
            "name" : "07-12-11_no231_weihnachtsmann.jpg",
            "url" : "http://localhost/core-stable5/public.php?service=files&t=0e72c30928c1faed00ff0602771b24bf",
            "shareWith" : "user@example.com"
         },
         {
            "permission" : 1,
            "shareType" : 4,
            "type" : "files",
            "shareWith" : "user@example.com",
            "name" : "07-12-11_no231_weihnachtsmann.jpg",
            "url" : "http://localhost/core-stable5/public.php?service=files&t=558af554cd3d0b41648c01b4b0ba6f8a",
            "shareId" : 242
         }
      ],
      "path" : "/07-12-11_no231_weihnachtsmann.jpg"
   },
   {
      "fileId" : 185,
      "path" : "/Beamer JVC HD1.jpg",
      "shares" : [
         {
            "type" : "files",
            "shareType" : 5,
            "permission" : 1,
            "shareId" : 241,
            "shareWith" : "user@example.com",
            "url" : "http://localhost/core-stable5/public.php?service=files&t=0e72c30928c1faed00ff0602771b24bf",
            "name" : "Beamer JVC HD1.jpg"
         },
         {
            "permission" : 1,
            "type" : "files",
            "shareType" : 4,
            "name" : "Beamer JVC HD1.jpg",
            "url" : "http://localhost/core-stable5/public.php?service=files&t=558af554cd3d0b41648c01b4b0ba6f8a",
            "shareWith" : "user@example.com",
            "shareId" : 242
         },
         {
            "shareId" : 291,
            "url" : "http://localhost/core-stable5/public.php?service=files&t=b88b2771c1c1a48beb9bcb0334123a7c",
            "name" : "Beamer JVC HD1.jpg",
            "shareWith" : null,
            "type" : "file",
            "shareType" : 3,
            "permission" : 1
         }
      ]
   }
]

@PVince81
Copy link
Contributor Author

@DeepDiver1975 at the moment ALL files are loaded in a JS array but only the 20 first are rendered in the table, so having the whole sharing should currently work.

But you are right, I could try making the share data available along with the file data instead, maybe a task for the ajaxification here: #6968
But I'm afraid that the PR there is already too big so not sure about adding new stuff... should we get it merged first ? (step by step / incremental)

@PVince81
Copy link
Contributor Author

@DeepDiver1975 I'll discuss this with Björn tomorrow as I still need to get familiar with the sharing API and will either add it into that PR or separately (a mix between the sharing task and files app performance improvements)

@DeepDiver1975
Copy link
Member

But I'm afraid that the PR there is already too big so not sure about adding new stuff... should we get it merged first ? (step by step / incremental)

For sure - my intention was to talk/discuss about the overall picture and concept.

@PVince81
Copy link
Contributor Author

@owncloud/designers question about infinite scroll.
Imagine you see the first 20 of a long file list, sorted from A to F alphabetically.
Scrolling down would give you G, H, etc
Let's say you upload a file that starts with "Z" or rename the file "A" to "Z".
What is supposed to happen ?
Do we:

  1. Reload the whole list ? (making the infinite scroll start from the first "page")
  2. Append/insert the file into the list ?

For 2) we could try and find out whether the file belongs to the current displayed range, if yes insert it, if not don't show it and let it appear as soon as the user scrolls down.

What do you think ?

@PVince81
Copy link
Contributor Author

Just tried this in IE8 (VM, not so strong computer) with 10000 files.
After the initial scan it took about 17 seconds to load the file list from the server, and then the scrolling went well.

Of course if you try and scroll to the bottom it will become slower over time, but at least you can open that folder without crashing the browser.

I'm surprised that even IE8 isn't bothered when loading 10000 file entries into a JS array.

@PVince81
Copy link
Contributor Author

CC @jancborchardt

I think this is already a nice improvement. I suggest we look into "API wise pagination" and "virtual scrolling" later (separate PR/future)

I'll try and optimize this one here a bit more.
I still have a few TODOs like make select all work with the trashbin.

@karlitschek
Copy link
Contributor

I agree. This is a nice improvement and kind of "good enough" TM because 10000 file in one directory is a corner case anyways.
Great work!!

@jancborchardt
Copy link
Member

Cool! After the scroll threshold improvement as we talked about, I’m fine with this. :) Design-wise this is a 👍 although I can’t judge if the code is ok.

@PVince81
Copy link
Contributor Author

Thanks for the design review.
I still need to fix the trashbin "restore" with select all and test the files app more thoroughly.

@PVince81
Copy link
Contributor Author

Please review #7195 first, which fixes the "select all" case when not all files are in the list

@jancborchardt
Copy link
Member

@PVince81 #7195 is in, can you fix the failed stuff and rebase?

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 2, 2014

Rebased on top of the ajaxification branch which is itself rebased on top of master so needs to be retested.

@MorrisJobke if you like you can test this branch instead of the ajaxification one... at least this way we can get the infinite scroll stuff in faster...

Then I'll need someone to look at the code.

@PVince81 PVince81 changed the title [WIP] Infinite scrolling for files app Infinite scrolling for files app Apr 2, 2014
@PVince81
Copy link
Contributor Author

PVince81 commented Apr 2, 2014

@schiesbn if you like I can guide you through the new code on this branch for a code review ?

@schiessle
Copy link
Contributor

reviewed the code together with @PVince81, looks good 👍

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 3, 2014

  • Bug: renaming a file puts it back to the beginning
  • When uploading/creating a new file: insert at the correct position if it exists, else don't. Do insert into internal JSON array.

@MorrisJobke
Copy link
Contributor

@PVince81 Rebase please (or just fast-forward ;))

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 4, 2014

Rebased.
You might want to hold testing for this until I've fixed the points above.

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 4, 2014

  • Open a folder with 40 files, delete the first 20 without scrolling down: next page should be loaded atuomatically, but isn't.

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 4, 2014

  • Open folder with 40 files without scrollng, click "select all" then unselect the first one. Total selected files does not match. Selection code needs to be revamped to be based off the "FileList.files" array instead of DOM.

I predict many future issues with this because many apps rely on the file names being in the DOM (for example slideshow). These apps will have to be adapted to rely on the FileList.files array.

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 8, 2014

Rebased and fixed selection to be now based on the internal array instead of the visible checkboxes...

Additional issues:

  • Drag and drop shadow has wrong file name order

@PVince81
Copy link
Contributor Author

PVince81 commented Apr 8, 2014

I think this should be ready to test now, I haven't redone a regression test at the moment, but here are some tests related to the required changes:

  • page of less than 20 files can be shown correctly
  • more than 20 files triggers infinite scrolling
  • open page with 40 files, delete the first 20: should auto-render next page
  • new/upload file which name is outside page, scroll down
  • new/upload file which name will appear in the page
  • file selection
  • selection with ctrl/shift
  • selection + infscroll not scrolled yet
  • select all, deselect one
  • drag and drop single file
  • drag and drop multiple files

Vincent Petry added 11 commits April 28, 2014 14:55
- moved file selection code to FileList
- fix selection summary when all files are selected
- nextPage now auto-selects files if "select all" checkbox is checked
- fixed trashbin to use the same selection logic as FileList
The FileList.files model is now updated with file operations.
Adding files to the list will add to the model first, then to the DOM.
If the insertion point isn't visible yet, the file won't be added to the
DOM until the user scrolls down.

Updated unit tests to include checking for the correct insertion point.
Removed "insert" flag, inserting is by default for FileList.add().
Added "animate" flag to FileList.add().
Added logic to correctly detect when to insert/append elements whenever
the insertion point is visible or not.
Fixed "render next page" logic to work correctly when many pages of
files have been added.
The file selection is now based on the internal model array
FileList.files instead of the visible checkboxes.

This makes it possible to virtually select files that haven't been
rendered yet (select all, then deselect a visible one)

Added more unit tests for selection (with shift and ctrl as well)
Now using _.bind() for event handlers so we can use "this" which is more
readable than a static access to FileList.
Fixed drag and drop code to use FileList.getSelectedFiles() instead of
the visible DOM elements.
@PVince81
Copy link
Contributor Author

Rebased.

@scrutinizer-notifier
Copy link

A new inspection was created.

@schiessle
Copy link
Contributor

went through the code together with @PVince81 and saw how it works 👍

@scrutinizer-notifier
Copy link

A new inspection was created.

@DeepDiver1975
Copy link
Member

NICE! 👍

@ghost
Copy link

ghost commented Apr 28, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/4478/

DeepDiver1975 added a commit that referenced this pull request Apr 28, 2014
@DeepDiver1975 DeepDiver1975 merged commit e055a41 into master Apr 28, 2014
@DeepDiver1975 DeepDiver1975 deleted the files-ajaxload-infscroll branch April 28, 2014 15:39
@PVince81
Copy link
Contributor Author

Thanks! 🍸

@ghost
Copy link

ghost commented Apr 28, 2014

🚀 Test Passed. 🚀
Refer to this link for build results: https://ci.owncloud.org/job/pull-request-analyser/4481/

@alanv72
Copy link

alanv72 commented Apr 28, 2014

Trying to cherry-pick this branch for a OC6.02 install. After merging just the modified files, I'm getting this error in the owncloud.log file... {"app":"PHP","message":"Call to a member function getType() on a non-object at /www/beta/apps/files/index.php#45","level":3,"time":"2014-04-28T23:05:40+00:00"}

Any suggestions?

@DeepDiver1975
Copy link
Member

Use the master branch if you want to test thus feature. Cherry-pick will not work as many other changes are necessary

Von Samsung Mobile gesendet

-------- Ursprüngliche Nachricht --------
Von: alanv72 notifications@github.com
Datum:29.04.2014 01:09 (GMT+01:00)
An: owncloud/core core@noreply.github.com
Cc: Thomas Müller thomas.mueller@tmit.eu
Betreff: Re: [core] Infinite scrolling for files app (#7167)

Trying to cherry-pick this branch for a OC6.02 install. After merging just the modified files, I'm getting this error in the owncloud.log file... {"app":"PHP","message":"Call to a member function getType() on a non-object at /www/beta/apps/files/index.php#45","level":3,"time":"2014-04-28T23:05:40+00:00"}

Any suggestions?


Reply to this email directly or view it on GitHub.

@alanv72
Copy link

alanv72 commented Apr 29, 2014

Thanks! Sorry for the newbie question.. but what's the best way to know what pull request made it into the owncloud community editions? For example, how can I tell if this made it into 6.0.3?

@PVince81
Copy link
Contributor Author

Without juggling with git it's a bit hard to see.
Normally you could have a look at the changelog of 6.0.3 if it's in.

But generally speaking the stable branches (OC 6) only get bugfixes, no new features.
New features are developed on master, the next big version which is OC 7.

Even easier is to just ask in the PR 😉

@alanv72
Copy link

alanv72 commented Apr 29, 2014

Thanks for the info guys. Still trying to learn how to use github efficiently...

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants