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

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

Issue 486783006: Files.app: Update the list partially when changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the test filure & rebase Created 6 years, 4 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/directory_model.js » ('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/directory_contents.js
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index 10ca762e4b2cfd863986691d4016db35c5c25b5b..c1b0f2bc3947a9823f928f68e807d95b4cc921ac 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -663,6 +663,53 @@ DirectoryContents.prototype.scan = function(refresh) {
};
/**
+ * Adds/removes/updates items of file list.
+ * @param {Array.<Entry>} updatedEntries Entries of updated/added files.
+ * @param {Array.<string>} removedUrls URLs of removed files.
+ */
+DirectoryContents.prototype.update = function(updatedEntries, removedUrls) {
+ var removedMap = {};
+ for (var i = 0; i < removedUrls.length; i++) {
+ removedMap[removedUrls[i]] = true;
+ }
+
+ var updatedMap = {};
+ for (var i = 0; i < updatedEntries.length; i++) {
+ updatedMap[updatedEntries[i].toURL()] = updatedEntries[i];
+ }
+
+ var updatedList = [];
+ for (var i = 0; i < this.fileList_.length; i++) {
+ var url = this.fileList_.item(i).toURL();
+
+ if (url in removedMap) {
+ this.fileList_.splice(i, 1);
+ i--;
+ continue;
+ }
+
+ if (url in updatedMap) {
+ updatedList.push(updatedMap[url]);
+ delete updatedMap[url];
+ }
+ }
+
+ var addedList = [];
+ for (var url in updatedMap) {
+ addedList.push(updatedMap[url]);
+ }
+
+ if (removedUrls.length > 0)
+ this.fileList_.metadataCache_.clearByUrl(removedUrls, '*');
+
+ this.prefetchMetadata(updatedList, true, function() {
+ this.onNewEntries_(true, addedList);
+ this.onScanFinished_();
+ this.onScanCompleted_();
+ }.bind(this));
+};
+
+/**
* Cancels the running scan.
*/
DirectoryContents.prototype.cancelScan = function() {
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698