From a9637828959145858eccda5ae88b17f82a49a265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 2 Feb 2021 19:30:20 +0100 Subject: Properly catch missing context elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/files.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/files.js b/src/files.js index 3c657941..04a2b6d2 100644 --- a/src/files.js +++ b/src/files.js @@ -39,7 +39,7 @@ const odfViewer = { OC.imagePath('core', 'actions/rename'), (fileName, context) => { const fileModel = context.fileList.findFile(fileName) - const shareOwnerId = fileModel.shareOwnerId + const shareOwnerId = fileModel?.shareOwnerId return this.onEdit(fileName, { ...context, shareOwnerId }) }, t('richdocuments', 'Edit with {productName}', { productName: OC.getCapabilities().richdocuments.productName }, undefined, { escape: false }) @@ -72,7 +72,7 @@ const odfViewer = { } odfViewer.open = true if (context) { - if (context.$file.attr('data-mounttype') === 'external-session') { + if (context?.$file?.attr('data-mounttype') === 'external-session') { OCP.Toast.error(t('richdocuments', 'Opening the file is not supported, since the credentials for the external storage are not available without a session'), { timeout: 0 }) @@ -80,7 +80,7 @@ const odfViewer = { return } var fileDir = context.dir - var fileId = context.fileId || context.$file.attr('data-id') + var fileId = context.fileId || context.$file?.attr('data-id') var templateId = context.templateId } FilesAppIntegration.startLoading() @@ -134,7 +134,7 @@ const odfViewer = { } if (context) { - reloadForFederationCSP(fileName, context.shareOwnerId) + reloadForFederationCSP(fileName, context?.shareOwnerId) } $('head').append($('')) -- cgit v1.2.3