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

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

Issue 2932803002: Stop updating context menu task items when not changed. (Closed)
Patch Set: Compare selected entries instead of removing temporary item. Created 3 years, 6 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/task_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/task_controller.js b/ui/file_manager/file_manager/foreground/js/task_controller.js
index 8126570201a14582b44a6b63f40207c61487fe51..c7457d171270354a72faff62ed2170f1e8fde74a 100644
--- a/ui/file_manager/file_manager/foreground/js/task_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/task_controller.js
@@ -90,6 +90,11 @@ function TaskController(
*/
this.tasks_ = null;
+ /**
+ * @private {!Array<!Entry>}
+ */
+ this.lastSelectedEntries_ = [];
+
ui.taskMenuButton.addEventListener(
'select', this.onTaskItemClicked_.bind(this));
this.selectionHandler_.addEventListener(
@@ -267,14 +272,18 @@ TaskController.prototype.onSelectionChanged_ = function() {
// FileSelectionHandler.EventType.CHANGE
if (this.dialogType_ === DialogType.FULL_PAGE &&
(selection.directoryCount > 0 || selection.fileCount > 0)) {
- // Show disabled items for position calculation of the menu. They will be
- // overridden in this.updateFileSelectionAsync().
- this.updateContextMenuTaskItems_(
- [TaskController.createTemporaryDisabledTaskItem_()]);
+ // Compare entries while ignoring changes inside directories.
+ if (!util.isSameEntries(this.lastSelectedEntries_, selection.entries)) {
+ // Show disabled items for position calculation of the menu. They will be
+ // overridden in this.updateTasks_().
+ this.updateContextMenuTaskItems_(
+ [TaskController.createTemporaryDisabledTaskItem_()]);
+ }
} else {
// Update context menu.
this.updateContextMenuTaskItems_([]);
}
+ this.lastSelectedEntries_ = selection.entries;
};
/**
« 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