Skip to content

Commit

Permalink
Merge pull request #17536 from nextcloud/enh/noid/expose-current-file…
Browse files Browse the repository at this point in the history
…list

Expose currently active file list though OCA.Files.App
  • Loading branch information
skjnldsv committed Aug 26, 2020
2 parents 4298442 + d5e854e commit cb2695d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apps/files/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
*/
fileList: null,

currentFileList: null,

/**
* Backbone model for storing files preferences
*/
Expand Down Expand Up @@ -112,6 +114,7 @@
maxChunkSize: OC.appConfig.files && OC.appConfig.files.max_chunk_size
}
);
this.updateCurrentFileList(this.fileList)
this.files.initialize();

// for backward compatibility, the global FileList will
Expand Down Expand Up @@ -160,6 +163,28 @@
}
},

/**
* Set the currently active file list
*
* Due to the file list implementations being registered after clicking the
* navigation item for the first time, OCA.Files.App is not aware of those until
* they have initialized themselves. Therefore the files list needs to call this
* method manually
*
* @param {OCA.Files.FileList} newFileList
*/
updateCurrentFileList: function(newFileList) {
this.currentFileList = newFileList;
},

/**
* Return the currently active file list
* @return {?OCA.Files.FileList}
*/
getCurrentFileList: function () {
return this.currentFileList;
},

/**
* Returns the container of the currently visible app.
*
Expand Down
3 changes: 3 additions & 0 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@

OC.Plugins.attach('OCA.Files.FileList', this);

OCA.Files.App && OCA.Files.App.updateCurrentFileList(this);

this.initHeadersAndFooters()
},

Expand Down Expand Up @@ -738,6 +740,7 @@
* Event handler when leaving previously hidden state
*/
_onShow: function(e) {
OCA.Files.App && OCA.Files.App.updateCurrentFileList(this);
if (this.shown) {
if (e.itemId === this.id) {
this._setCurrentDir('/', false);
Expand Down

0 comments on commit cb2695d

Please sign in to comment.