summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r--apps/files_sharing/js/app.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js
index 1fc13d00382..1a3bfac5b97 100644
--- a/apps/files_sharing/js/app.js
+++ b/apps/files_sharing/js/app.js
@@ -92,6 +92,21 @@ OCA.Sharing.App = {
}
},
+ /**
+ * Destroy the app
+ */
+ destroy: function() {
+ OCA.Files.fileActions.off('setDefault.app-sharing', this._onActionsUpdated);
+ OCA.Files.fileActions.off('registerAction.app-sharing', this._onActionsUpdated);
+ this.removeSharingIn();
+ this.removeSharingOut();
+ this.removeSharingLinks();
+ this._inFileList = null;
+ this._outFileList = null;
+ this._linkFileList = null;
+ delete this._globalActionsInitialized;
+ },
+
_createFileActions: function() {
// inherit file actions from the files app
var fileActions = new OCA.Files.FileActions();
@@ -100,6 +115,14 @@ OCA.Sharing.App = {
fileActions.registerDefaultActions();
fileActions.merge(OCA.Files.fileActions);
+ if (!this._globalActionsInitialized) {
+ // in case actions are registered later
+ this._onActionsUpdated = _.bind(this._onActionsUpdated, this);
+ OCA.Files.fileActions.on('setDefault.app-sharing', this._onActionsUpdated);
+ OCA.Files.fileActions.on('registerAction.app-sharing', this._onActionsUpdated);
+ this._globalActionsInitialized = true;
+ }
+
// when the user clicks on a folder, redirect to the corresponding
// folder in the files app instead of opening it directly
fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
@@ -110,6 +133,23 @@ OCA.Sharing.App = {
return fileActions;
},
+ _onActionsUpdated: function(ev) {
+ _.each([this._inFileList, this._outFileList, this._linkFileList], function(list) {
+ if (!list) {
+ return;
+ }
+
+ if (ev.action) {
+ list.fileActions.registerAction(ev.action);
+ } else if (ev.defaultAction) {
+ list.fileActions.setDefault(
+ ev.defaultAction.mime,
+ ev.defaultAction.name
+ );
+ }
+ });
+ },
+
_extendFileList: function(fileList) {
// remove size column from summary
fileList.fileSummary.$el.find('.filesize').remove();