0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-16 17:24:10 +00:00

filelist only refreshed if directory changes

check introduced at another method

comment added to explain one check

comment added to explain one check

unit tests added

small fixes in unit tests

missing semicolon added

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
noveens 2017-03-01 17:27:48 +05:30 committed by Morris Jobke
parent 53195b156c
commit 93f9db4d59
No known key found for this signature in database
GPG key ID: 9CE5ED29E7FCD38A
2 changed files with 23 additions and 0 deletions
apps/files

View file

@ -557,6 +557,11 @@
*/
_onUrlChanged: function(e) {
if (e && _.isString(e.dir)) {
var currentDir = this.getCurrentDirectory();
// this._currentDirectory is NULL when fileList is first initialised
if( (this._currentDirectory || this.$el.find('#dir').val()) && currentDir === e.dir) {
return;
}
this.changeDirectory(e.dir, false, true);
}
},

View file

@ -3005,4 +3005,22 @@ describe('OCA.Files.FileList tests', function() {
testMountType(123, 'external-root', 'external', 'external');
});
});
describe('file list should not refresh if url does not change', function() {
var fileListStub;
beforeEach(function() {
fileListStub = sinon.stub(OCA.Files.FileList.prototype, 'changeDirectory');
});
afterEach(function() {
fileListStub.restore();
});
it('File list must not be refreshed', function() {
$('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/subdir'}));
expect(fileListStub.notCalled).toEqual(true);
});
it('File list must be refreshed', function() {
$('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/'}));
expect(fileListStub.notCalled).toEqual(false);
});
});
});