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

Unified Diff: ui/file_manager/gallery/js/gallery_data_model.js

Issue 853653004: Gallery: Add items to GalleryDataModel before loading their metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 years, 8 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 | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/gallery_data_model_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/gallery_data_model.js
diff --git a/ui/file_manager/gallery/js/gallery_data_model.js b/ui/file_manager/gallery/js/gallery_data_model.js
index cac6d65a9a791d2337beabaf8ae3520282e2e45d..5bab3da76873545c7bb5a1575b846c2cf5cb3c89 100644
--- a/ui/file_manager/gallery/js/gallery_data_model.js
+++ b/ui/file_manager/gallery/js/gallery_data_model.js
@@ -64,8 +64,6 @@ GalleryDataModel.prototype = {
GalleryDataModel.prototype.saveItem = function(
volumeManager, item, canvas, overwrite) {
var oldEntry = item.getEntry();
- var oldMetadataItem = item.getMetadataItem();
- var oldThumbnailMetadataItem = item.getThumbnailMetadataItem();
var oldLocationInfo = item.getLocationInfo();
return new Promise(function(fulfill, reject) {
item.saveToFile(
@@ -89,22 +87,28 @@ GalleryDataModel.prototype.saveItem = function(
this.dispatchEvent(event);
if (!util.isSameEntry(oldEntry, item.getEntry())) {
- // New entry is added and the item now tracks it.
- // Add another item for the old entry.
- var anotherItem = new Gallery.Item(
- oldEntry,
- oldLocationInfo,
- oldMetadataItem,
- oldThumbnailMetadataItem,
- item.isOriginal());
- // The item must be added behind the existing item so that it does
- // not change the index of the existing item.
- // TODO(hirono): Update the item index of the selection model
- // correctly.
- this.splice(this.indexOf(item) + 1, 0, anotherItem);
+ Promise.all([
+ this.metadataModel_.get(
+ [oldEntry], Gallery.PREFETCH_PROPERTY_NAMES),
+ new ThumbnailModel(this.metadataModel_).get([oldEntry])
+ ]).then(function(itemLists) {
+ // New entry is added and the item now tracks it.
+ // Add another item for the old entry.
+ var anotherItem = new Gallery.Item(
+ oldEntry,
+ oldLocationInfo,
+ itemLists[0][0],
+ itemLists[1][0],
+ item.isOriginal());
+ // The item must be added behind the existing item so that it does
+ // not change the index of the existing item.
+ // TODO(hirono): Update the item index of the selection model
+ // correctly.
+ this.splice(this.indexOf(item) + 1, 0, anotherItem);
+ }.bind(this)).then(fulfill, reject);
+ } else {
+ fulfill();
}
-
- fulfill();
}.bind(this));
}.bind(this));
};
« no previous file with comments | « ui/file_manager/gallery/js/gallery.js ('k') | ui/file_manager/gallery/js/gallery_data_model_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698