Skip to content

Commit cffed68

Browse files
committed
fix(files): Only execute default action if there is an action to perform
Some files do not have a default action (can not be viewed and only downloaded). If the `openfile` query is set on them the `handleOpenFile` will throw an error. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 5866e49 commit cffed68

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

apps/files/src/components/FilesListVirtual.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,18 @@ export default defineComponent({
258258
259259
logger.debug('Opening file ' + node.path, { node })
260260
this.openFileId = fileId
261-
getFileActions()
262-
.filter(action => !action.enabled || action.enabled([node], this.currentView))
261+
const defaultAction = getFileActions()
262+
// Get only default actions (visible and hidden)
263+
.filter(action => !!action?.default)
264+
// Find actions that are either always enabled or enabled for the current node
265+
.filter((action) => !action.enabled || action.enabled([node], this.currentView))
266+
// Sort enabled default actions by order
263267
.sort((a, b) => (a.order || 0) - (b.order || 0))
264-
.filter(action => !!action?.default)[0].exec(node, this.currentView, this.currentFolder.path)
265-
},
266-
267-
getFileId(node) {
268-
return node.fileid
268+
// Get the first one
269+
.at(0)
270+
// Some file types do not have a default action (e.g. they can only be downloaded)
271+
// So if there is an enabled default action, so execute it
272+
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
269273
},
270274
271275
onDragOver(event: DragEvent) {

0 commit comments

Comments
 (0)