Skip to content

Commit 8ce75c0

Browse files
committed
refactor: destructure files action contexts
Signed-off-by: Elizabeth Danzberger <[email protected]>
1 parent 84efb28 commit 8ce75c0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/file-actions.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ const openPdf = new FileAction({
2323
{ productName: getCapabilities().productName })
2424
},
2525

26-
enabled: (files) => {
27-
if (files.length !== 1) {
26+
enabled: ({ nodes }) => {
27+
if (nodes.length !== 1) {
2828
return false
2929
}
3030

31-
const isPdf = files[0].mime === 'application/pdf'
31+
const isPdf = nodes[0].mime === 'application/pdf'
3232
// Only enable the file action when files_pdfviewer is enabled
3333
const optionalMimetypes = getCapabilities().mimetypesNoDefaultOpen
3434
return isPdf && optionalMimetypes.includes('application/pdf')
3535
},
3636

37-
exec: (file) => {
37+
exec: ({ nodes }) => {
38+
const file = nodes[0]
39+
3840
// If no viewer API, we can't open the document
3941
if (!OCA.Viewer) {
4042
return

0 commit comments

Comments
 (0)