Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js

Issue 886503006: Handle sorted event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/list_thumbnail_loader_unittest.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js
diff --git a/ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js b/ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js
index ba73fa46bbadce0436fb4014c69ffc3e9dad3e76..8c6b44a46489e849b1eb500e2f1bba7ea35a9610 100644
--- a/ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js
+++ b/ui/file_manager/file_manager/foreground/js/list_thumbnail_loader.js
@@ -10,16 +10,6 @@
* is responsible to return dataUrls of valid thumbnails and fetch them with
* proper priority.
*
- * TODOs
- * The following list is a todo list for this class. This list will be deleted
- * after all of them are implemented.
- * * Done: Fetch thumbnails with range based priority control.
- * * Done: Implement cache size limitation.
- * * Done: Modest queueing for low priority thumbnail fetches.
- * * Handle other event types of FileListModel, e.g. sort.
- * * Done: Change ThumbnailLoader to directly return dataUrl.
- * * Handle file types for which generic images are used.
- *
* @param {!FileListModel} dataModel A file list model.
* @param {!MetadataCache} metadataCache Metadata cache.
* @param {!Document} document Document.
@@ -89,8 +79,10 @@ function ListThumbnailLoader(
*/
this.cursor_ = 0;
- // TODO(yawano): Handle other event types of FileListModel, e.g. sort.
+ // TODO(yawano): Change FileListModel to dispatch change event for file
+ // change, and change this class to handle it.
this.dataModel_.addEventListener('splice', this.onSplice_.bind(this));
+ this.dataModel_.addEventListener('sorted', this.onSorted_.bind(this));
}
ListThumbnailLoader.prototype.__proto__ = cr.EventTarget.prototype;
@@ -126,6 +118,17 @@ ListThumbnailLoader.prototype.onSplice_ = function(event) {
}
/**
+ * An event handler for sorted event of data model. When list is sorted, start
+ * to rescan items.
+ *
+ * @param {!Event} event Event
+ */
+ListThumbnailLoader.prototype.onSorted_ = function(event) {
+ this.cursor_ = this.beginIndex_;
+ this.continue_();
+}
+
+/**
* Sets high priority range in the list.
*
* @param {number} beginIndex Begin index of the range, inclusive.
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/list_thumbnail_loader_unittest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698