Skip to content

Commit ace4b50

Browse files
susnuxskjnldsv
authored andcommitted
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 a0ede57 commit ace4b50

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

apps/files/src/components/FilesListVirtual.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,18 @@ export default defineComponent({
275275
276276
logger.debug('Opening file ' + node.path, { node })
277277
this.openFileId = fileId
278-
getFileActions()
279-
.filter(action => !action.enabled || action.enabled([node], this.currentView))
278+
const defaultAction = getFileActions()
279+
// Get only default actions (visible and hidden)
280+
.filter(action => !!action?.default)
281+
// Find actions that are either always enabled or enabled for the current node
282+
.filter((action) => !action.enabled || action.enabled([node], this.currentView))
283+
// Sort enabled default actions by order
280284
.sort((a, b) => (a.order || 0) - (b.order || 0))
281-
.filter(action => !!action?.default)[0].exec(node, this.currentView, this.currentFolder.path)
282-
},
283-
284-
getFileId(node) {
285-
return node.fileid
285+
// Get the first one
286+
.at(0)
287+
// Some file types do not have a default action (e.g. they can only be downloaded)
288+
// So if there is an enabled default action, so execute it
289+
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
286290
},
287291
288292
onDragOver(event: DragEvent) {

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)