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..a703d14c00d7f9c8d5a5109887dd38fb1940e018 100644 |
--- a/ui/file_manager/file_manager/foreground/js/task_controller.js |
+++ b/ui/file_manager/file_manager/foreground/js/task_controller.js |
@@ -262,6 +262,7 @@ |
* @private |
*/ |
TaskController.prototype.onSelectionChanged_ = function() { |
+ this.tasks_ = null; |
var selection = this.selectionHandler_.selection; |
// Caller of update context menu task items. |
// FileSelectionHandler.EventType.CHANGE |
@@ -285,36 +286,15 @@ |
var selection = this.selectionHandler_.selection; |
if (this.dialogType_ === DialogType.FULL_PAGE && |
(selection.directoryCount > 0 || selection.fileCount > 0)) { |
- var previousFileTasksInvalidatePromise = new Promise(function(resolve) { |
- if (this.tasks_) { |
- this.getFileTasks() |
- .then(function(tasks) { |
- if (!util.isSameEntries(tasks.entries, selection.entries)) { |
- this.tasks_ = null; |
- } |
- resolve(); |
- }.bind(this)) |
- .catch(function(error) { |
- if (error) |
- console.log(error.stack || error); |
- this.tasks_ = null; |
- resolve(); |
- }.bind(this)); |
- } else { |
- resolve(); |
- } |
- }.bind(this)); |
- previousFileTasksInvalidatePromise.then(function() { |
- this.getFileTasks() |
- .then(function(tasks) { |
- tasks.display(this.ui_.taskMenuButton); |
- this.updateContextMenuTaskItems_(tasks.getTaskItems()); |
- }.bind(this)) |
- .catch(function(error) { |
- if (error) |
- console.error(error.stack || error); |
- }); |
- }.bind(this)); |
+ this.getFileTasks() |
+ .then(function(tasks) { |
+ tasks.display(this.ui_.taskMenuButton); |
+ this.updateContextMenuTaskItems_(tasks.getTaskItems()); |
+ }.bind(this)) |
+ .catch(function(error) { |
+ if (error) |
+ console.error(error.stack || error); |
+ }); |
} else { |
this.ui_.taskMenuButton.hidden = true; |
} |
@@ -329,21 +309,19 @@ |
return this.tasks_; |
var selection = this.selectionHandler_.selection; |
- return this.tasks_ = |
- selection.computeAdditional(this.metadataModel_).then(function() { |
- if (this.selectionHandler_.selection !== selection) |
- return Promise.reject(); |
- return FileTasks |
- .create( |
- this.volumeManager_, this.metadataModel_, |
- this.directoryModel_, this.ui_, selection.entries, |
- assert(selection.mimeTypes)) |
- .then(function(tasks) { |
- if (this.selectionHandler_.selection !== selection) |
- return Promise.reject(); |
- return tasks; |
- }.bind(this)); |
- }.bind(this)); |
+ return selection.computeAdditional(this.metadataModel_).then( |
+ function() { |
+ if (this.selectionHandler_.selection !== selection) |
+ return Promise.reject(); |
+ return FileTasks.create( |
+ this.volumeManager_, this.metadataModel_, this.directoryModel_, |
+ this.ui_, selection.entries, assert(selection.mimeTypes)). |
+ then(function(tasks) { |
+ if (this.selectionHandler_.selection !== selection) |
+ return Promise.reject(); |
+ return tasks; |
+ }.bind(this)); |
+ }.bind(this)); |
}; |
/** |