From 94ac7b7564aac425bdb4dd601e30249c969e5dd5 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Fri, 15 Nov 2024 08:54:41 +0100 Subject: [PATCH] fix: Limit open with Collabora action to pdf files Signed-off-by: Julius Knorr --- src/file-actions.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/file-actions.js b/src/file-actions.js index 4c33583821..76317a3df9 100644 --- a/src/file-actions.js +++ b/src/file-actions.js @@ -23,10 +23,15 @@ const openPdf = new FileAction({ { productName: getCapabilities().productName }) }, - enabled: () => { + enabled: (files) => { + if (files.length !== 1) { + return false + } + + const isPdf = files[0].mime === 'application/pdf' // Only enable the file action when files_pdfviewer is enabled const optionalMimetypes = getCapabilities().mimetypesNoDefaultOpen - return optionalMimetypes.includes('application/pdf') + return isPdf && optionalMimetypes.includes('application/pdf') }, exec: (file) => {