From 02982d59f79cf86fe850afa4f40506d431cfc04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 7 Oct 2019 15:54:33 +0200 Subject: Move file list access to files app integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/view/FilesAppIntegration.js | 26 +++++++++++++++++++++----- src/viewer.js | 19 +++++++------------ 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/view/FilesAppIntegration.js b/src/view/FilesAppIntegration.js index e8e1a248..da5c0a8f 100644 --- a/src/view/FilesAppIntegration.js +++ b/src/view/FilesAppIntegration.js @@ -25,6 +25,9 @@ const isPublic = document.getElementById('isPublic') && document.getElementById( export default { fileModel: null, + + fileList: FileList, + /* Views: people currently editing the file */ views: {}, @@ -32,15 +35,17 @@ export default { following: null, - init({ fileName, fileId, sendPostMessage }) { + init({ fileName, fileId, sendPostMessage, fileList }) { this.fileName = fileName this.fileId = fileId + this.fileList = fileList this.sendPostMessage = sendPostMessage }, initAfterReady() { if (typeof this.getFileList() !== 'undefined') { this.getFileModel() + this.getFileList().hideMask() } const headerRight = document.querySelector('#header .header-right') @@ -57,6 +62,10 @@ export default { }, close() { + if (this.getFileList()) { + this.getFileList().setViewerMode(false) + this.getFileList().reload() + } this.fileModel = null if (!isPublic) { this.removeVersionSidebarEvents() @@ -65,10 +74,11 @@ export default { }, share() { - if (isPublic) { + if (isPublic || !this.getFileList()) { console.error('[FilesAppIntegration] Sharing is not supported') + return } - FileList.showDetailsView(this.fileName, 'shareTabView') + this.getFileList().showDetailsView(this.fileName, 'shareTabView') OC.Apps.showAppSidebar() }, @@ -93,6 +103,9 @@ export default { }, getFileList() { + if (this.fileList) { + return this.fileList + } if (OCA.Files.App) { return OCA.Files.App.fileList } @@ -341,8 +354,11 @@ export default { }, showRevHistory() { - FileList.showDetailsView(this.fileName, 'versionsTabView') - this.addCurrentVersion() + if (this.getFileList()) { + this.getFileList() + .showDetailsView(this.fileName, 'versionsTabView') + this.addCurrentVersion() + } }, showVersionPreview: function(e) { diff --git a/src/viewer.js b/src/viewer.js index 223953c1..1fabe145 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -62,13 +62,15 @@ const odfViewer = { return } odfViewer.open = true + let fileList = FileList if (context) { + fileList = context.fileList var fileDir = context.dir var fileId = context.fileId || context.$file.attr('data-id') var templateId = context.templateId - FileList.setViewerMode(true) - FileList.setPageTitle(fileName) - FileList.showMask() + context.fileList.setViewerMode(true) + context.fileList.setPageTitle(fileName) + context.fileList.showMask() } odfViewer.receivedLoading = false @@ -103,7 +105,7 @@ const odfViewer = { const reloadForFederationCSP = (fileName) => { const preloadId = Preload.open ? parseInt(Preload.open.id) : -1 - const fileModel = FileList.findFile(fileName) + const fileModel = fileList.findFile(fileName) const shareOwnerId = fileModel.shareOwnerId if (typeof shareOwnerId !== 'undefined') { const lastIndex = shareOwnerId.lastIndexOf('@') @@ -157,6 +159,7 @@ const odfViewer = { FilesAppIntegration.init({ fileName, fileId, + fileList, sendPostMessage: (msgId, values) => { PostMessages.sendWOPIPostMessage(FRAME_DOCUMENT, msgId, values) } @@ -169,20 +172,12 @@ const odfViewer = { $('#richdocumentsframe').show() $('html, body').scrollTop(0) $('#content').removeClass('loading') - if (typeof FileList !== 'undefined') { - FileList.hideMask() - } FilesAppIntegration.initAfterReady() }, onClose: function() { odfViewer.open = false clearTimeout(odfViewer.loadingTimeout) - if (typeof FileList !== 'undefined') { - FileList.setViewerMode(false) - FileList.reload() - // FileList.scrollTo() - } odfViewer.receivedLoading = false $('link[href*="richdocuments/css/mobile"]').remove() $('#app-content #controls').removeClass('hidden') -- cgit v1.2.3