Skip to content

Commit

Permalink
Reload file list when leaving hidden state
Browse files Browse the repository at this point in the history
Whenever a file list is already initialized and was hidden when
switching to another file list in the navigation bar, if the user comes
back to this list it gets redisplayed. At this point the list needs to
be refreshed to be able to reflect any potential file changes done from
the other lists.
  • Loading branch information
Vincent Petry committed Apr 20, 2017
1 parent 718d85b commit 8924d84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this));

this.$fileList.on('change', 'td.filename>.selectCheckBox', _.bind(this._onClickFileCheckbox, this));
this.$el.on('show', _.bind(this._onShow, this));
this.$el.on('urlChanged', _.bind(this._onUrlChanged, this));
this.$el.find('.select-all').click(_.bind(this._onClickSelectAll, this));
this.$el.find('.download').click(_.bind(this._onClickDownloadSelected, this));
Expand Down Expand Up @@ -544,6 +545,13 @@
this.$table.find('>thead').width($('#app-content').width() - OC.Util.getScrollBarWidth());
},

/**
* Event handler when leaving previously hidden state
*/
_onShow: function(e) {
this.reload();
},

/**
* Event handler for when the URL changed
*/
Expand Down
6 changes: 6 additions & 0 deletions apps/files/tests/js/filelistSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,12 @@ describe('OCA.Files.FileList tests', function() {
$('#app-content-files').trigger(new $.Event('urlChanged', {view: 'files', dir: '/somedir'}));
expect(fileList.getCurrentDirectory()).toEqual('/somedir');
});
it('reloads the list when leaving hidden state', function() {
var reloadStub = sinon.stub(fileList, 'reload');
$('#app-content-files').trigger(new $.Event('show'));
expect(reloadStub.calledOnce).toEqual(true);
reloadStub.restore();
});
it('refreshes breadcrumb after update', function() {
var setDirSpy = sinon.spy(fileList.breadcrumb, 'setDirectory');
fileList.changeDirectory('/anothersubdir');
Expand Down

0 comments on commit 8924d84

Please sign in to comment.