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

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

Issue 931603002: Update the thumbnail when a file is updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failed test case. 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
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 1bf53237200b9edeb71056efef4e49d187624bd3..731f5ec7da263c6a3c1da6517208763ecec84f54 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
@@ -76,6 +76,7 @@ function ListThumbnailLoader(
// change, and change this class to handle it.
this.dataModel_.addEventListener('splice', this.onSplice_.bind(this));
this.dataModel_.addEventListener('sorted', this.onSorted_.bind(this));
+ this.dataModel_.addEventListener('change', this.onChange_.bind(this));
}
ListThumbnailLoader.prototype.__proto__ = cr.EventTarget.prototype;
@@ -122,6 +123,21 @@ ListThumbnailLoader.prototype.onSorted_ = function(event) {
}
/**
+ * An event handler for change event of data model.
+ *
+ * @param {!Event} event Event
+ */
+ListThumbnailLoader.prototype.onChange_ = function(event) {
+ // Revoke cache of updated file.
+ var item = this.dataModel_.item(event.index);
+ if (item)
+ this.cache_.remove(item.toURL());
+
+ this.cursor_ = this.beginIndex_;
+ this.continue_();
+}
+
+/**
* Sets high priority range in the list.
*
* @param {number} beginIndex Begin index of the range, inclusive.
@@ -318,11 +334,11 @@ ListThumbnailLoader.Task = function(
*/
ListThumbnailLoader.Task.prototype.fetch = function() {
return new Promise(function(resolve, reject) {
- this.metadataCache_.getOne(
- this.entry_, 'thumbnail|filesystem|external|media', resolve);
- }.bind(this)).then(function(metadata) {
+ this.metadataCache_.getLatest(
+ [this.entry_], 'thumbnail|filesystem|external|media', resolve);
+ }.bind(this)).then(function(metadatas) {
return new this.thumbnailLoaderConstructor_(
- this.entry_, ThumbnailLoader.LoaderType.IMAGE, metadata)
+ this.entry_, ThumbnailLoader.LoaderType.IMAGE, metadatas[0])
.loadAsDataUrl();
}.bind(this)).then(function(result) {
return new ListThumbnailLoader.ThumbnailData(

Powered by Google App Engine
This is Rietveld 408576698