Skip to content

Commit 01f885e

Browse files
committed
Use only one DetailsView instance across all filelist types
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent bcb5b0d commit 01f885e

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

apps/files/js/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
*/
4141
fileList: null,
4242

43+
/**
44+
* File details view
45+
*
46+
* @member {OCA.Files.DetailsView}
47+
*/
48+
detailsView: null,
49+
4350
/**
4451
* Backbone model for storing files preferences
4552
*/

apps/files/js/filelist.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,21 @@
272272
this.$el.toggleClass('hide-hidden-files', !this._filesConfig.get('showhidden'));
273273
}
274274

275+
this._initFileActions(options.fileActions);
275276

276277
if (_.isUndefined(options.detailsViewEnabled) || options.detailsViewEnabled) {
277-
this._detailsView = new OCA.Files.DetailsView();
278+
if (OCA.Files.App.detailsView === null) {
279+
OCA.Files.App.detailsView = new OCA.Files.DetailsView();
280+
OCA.Files.App.detailsView.initialize();
281+
282+
this._detailsView = OCA.Files.App.detailsView;
283+
this._detailsView.addDetailView(new OCA.Files.MainFileInfoDetailView({fileList: this, fileActions: this.fileActions}));
284+
}
285+
this._detailsView = OCA.Files.App.detailsView;
278286
this._detailsView.$el.addClass('disappear');
279287
}
280-
281288
this._initFileActions(options.fileActions);
282289

283-
if (this._detailsView) {
284-
this._detailsView.addDetailView(new OCA.Files.MainFileInfoDetailView({fileList: this, fileActions: this.fileActions}));
285-
}
286-
287290
this.files = [];
288291
this._selectedFiles = {};
289292
this._selectionSummary = new OCA.Files.FileSummary(undefined, {config: this._filesConfig});
@@ -374,7 +377,6 @@
374377
}
375378
}
376379

377-
378380
OC.Plugins.attach('OCA.Files.FileList', this);
379381
},
380382

@@ -388,9 +390,7 @@
388390
if (this._newButton) {
389391
this._newButton.remove();
390392
}
391-
if (this._detailsView) {
392-
this._detailsView.remove();
393-
}
393+
394394
// TODO: also unregister other event handlers
395395
this.fileActions.off('registerAction', this._onFileActionsUpdated);
396396
this.fileActions.off('setDefault', this._onFileActionsUpdated);
@@ -3327,7 +3327,7 @@
33273327
* Register a tab view to be added to all views
33283328
*/
33293329
registerTabView: function(tabView) {
3330-
if (this._detailsView) {
3330+
if (this._detailsView && (OCA.Files.App.fileList === null || OCA.Files.App.fileList === this)) {
33313331
this._detailsView.addTabView(tabView);
33323332
}
33333333
},
@@ -3336,7 +3336,7 @@
33363336
* Register a detail view to be added to all views
33373337
*/
33383338
registerDetailView: function(detailView) {
3339-
if (this._detailsView) {
3339+
if (this._detailsView && (OCA.Files.App.fileList === null || OCA.Files.App.fileList === this)) {
33403340
this._detailsView.addDetailView(detailView);
33413341
}
33423342
},

0 commit comments

Comments
 (0)