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

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

Issue 2843683002: Reuse File objects in FileTransferController. (Closed)
Patch Set: Fix error. Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/file_transfer_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js
index 35ecd10b61ec694a1f9da2a66a4438a4b6fd9a87..10156bd01a260dea7a611df09368538f6629574c 100644
--- a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js
@@ -1261,7 +1261,16 @@ FileTransferController.prototype.simulateCommand_ = function(command, handler) {
*/
FileTransferController.prototype.onFileSelectionChanged_ = function() {
this.preloadedThumbnailImagePromise_ = null;
- this.selectedAsyncData_ = {};
+ // Remove file objects that are no longer in the selection.
fukino 2017/04/26 07:14:31 It might be better to place this logic in onFileSe
tetsui2 2017/04/26 07:42:31 Done.
+ var newSelectedAsyncData = {};
+ var entries = this.selectionHandler_.selection.entries;
+ for (var i = 0; i < entries.length; i++) {
+ var entryUrl = entries[i].toURL();
+ if (entryUrl in this.selectedAsyncData_) {
+ newSelectedAsyncData[entryUrl] = this.selectedAsyncData_[entryUrl];
+ }
+ }
+ this.selectedAsyncData_ = newSelectedAsyncData;
};
/**
@@ -1274,7 +1283,9 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() {
for (var i = 0; i < entries.length; i++) {
if (entries[i].isFile)
fileEntries.push(entries[i]);
- asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null};
+ if (!(entries[i].toURL() in asyncData)) {
+ asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null};
+ }
}
var containsDirectory = this.selectionHandler_.selection.directoryCount > 0;
@@ -1285,9 +1296,11 @@ FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() {
if (!containsDirectory) {
for (var i = 0; i < fileEntries.length; i++) {
(function(fileEntry) {
- fileEntry.file(function(file) {
- asyncData[fileEntry.toURL()].file = file;
- });
+ if (!(asyncData[fileEntry.toURL()].file)) {
+ fileEntry.file(function(file) {
+ asyncData[fileEntry.toURL()].file = file;
+ });
+ }
})(fileEntries[i]);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698