diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-09 12:26:33 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-09 12:26:33 +0200 |
commit | 22653e21a239afa8f29cf2c93afe28d21246e7ba (patch) | |
tree | cacee44aabacafe6ce35ce82a4e62afa7cdaab1e /apps/files/js/app.js | |
parent | 63fdaacbfcc8dbccca6777d623b6baadbd0ed56b (diff) | |
download | nextcloud-server-22653e21a239afa8f29cf2c93afe28d21246e7ba.tar.gz nextcloud-server-22653e21a239afa8f29cf2c93afe28d21246e7ba.zip |
Propagate file action changes to the file lists
Whenever an app needs to register an event late, it does that on the
original file actions object.
Since the file actions that the file list work on is a merged list, not
the original one, the registration event needs to be propagated there as
well.
Diffstat (limited to 'apps/files/js/app.js')
-rw-r--r-- | apps/files/js/app.js | 34 |
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 |