summaryrefslogtreecommitdiffstats
path: root/apps/files/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/app.js')
-rw-r--r--apps/files/js/app.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 45b6b6a0e16..6f5206fcdb6 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -32,9 +32,11 @@
// regular actions
fileActions.merge(OCA.Files.fileActions);
- // in case apps would decide to register file actions later,
- // replace the global object with this one
- OCA.Files.fileActions = fileActions;
+ this._onActionsUpdated = _.bind(this._onActionsUpdated, this);
+ OCA.Files.fileActions.on('setDefault.app-files', this._onActionsUpdated);
+ OCA.Files.fileActions.on('registerAction.app-files', this._onActionsUpdated);
+ window.FileActions.on('setDefault.app-files', this._onActionsUpdated);
+ window.FileActions.on('registerAction.app-files', this._onActionsUpdated);
this.files = OCA.Files.Files;
@@ -60,6 +62,32 @@
},
/**
+ * Destroy the app
+ */
+ destroy: function() {
+ this.navigation = null;
+ this.fileList.destroy();
+ this.fileList = null;
+ this.files = null;
+ OCA.Files.fileActions.off('setDefault.app-files', this._onActionsUpdated);
+ OCA.Files.fileActions.off('registerAction.app-files', this._onActionsUpdated);
+ window.FileActions.off('setDefault.app-files', this._onActionsUpdated);
+ window.FileActions.off('registerAction.app-files', this._onActionsUpdated);
+ },
+
+ _onActionsUpdated: function(ev, newAction) {
+ // forward new action to the file list
+ if (ev.action) {
+ this.fileList.fileActions.registerAction(ev.action);
+ } else if (ev.defaultAction) {
+ this.fileList.fileActions.setDefault(
+ ev.defaultAction.mime,
+ ev.defaultAction.name
+ );
+ }
+ },
+
+ /**
* Returns the container of the currently visible app.
*
* @return app container