diff --git a/src/init.ts b/src/init.ts index 1c6db60..730ea68 100644 --- a/src/init.ts +++ b/src/init.ts @@ -1,4 +1,5 @@ import { + DefaultType, FileAction, FileType, Node, @@ -7,19 +8,16 @@ import { } from '@nextcloud/files' import cores from './mime.json' import { generateUrl } from '@nextcloud/router' +import icon from '../img/app.svg?raw' import { t } from '@nextcloud/l10n' const getCore = (file: Node) => { - if ( - !file.fileid || - file.type !== FileType.File || - !(file.permissions & Permission.READ) - ) - return false - const extension = file.extension?.substring(1) - for (const core in cores) { - if (cores[core].types.includes(file.mime)) return core - if (cores[core].extensions.includes(extension)) return core + if (file.type === FileType.File && file.permissions & Permission.READ) { + const extension = file.extension?.substring(1) + for (const core in cores) { + if (cores[core].types.includes(file.mime)) return core + if (cores[core].extensions.includes(extension)) return core + } } return false } @@ -27,7 +25,7 @@ const getCore = (file: Node) => { const action = new FileAction({ id: 'retro', displayName: () => t('repod', 'Play'), - iconSvgInline: () => '', + iconSvgInline: () => icon, enabled: (files: Node[]) => { if (files.length !== 1) return false return !!getCore(files[0]) @@ -39,6 +37,7 @@ const action = new FileAction({ }) return true }, + default: DefaultType.DEFAULT, }) registerFileAction(action) diff --git a/tsconfig.json b/tsconfig.json index 190d375..b98d16d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,5 +10,6 @@ "rootDir": ".", "strict": true, "noEmit": true, + "types": ["vite/client"], } }