From a3f663a2ffa54056defd4604f6238743a7865363 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 20 Feb 2025 12:56:19 +0100 Subject: [PATCH] fix(files): Ensure the filter instance is mounted `reset` could be called before the filters are mounted, in this case it is valid to update the presets, but we must not try to access the vue instance (as it does not exist yet). Signed-off-by: Ferdinand Thiessen --- apps/files/src/filters/HiddenFilesFilter.ts | 2 +- apps/files/src/filters/TypeFilter.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files/src/filters/HiddenFilesFilter.ts b/apps/files/src/filters/HiddenFilesFilter.ts index 51d90b2efb2..e48881d4ab7 100644 --- a/apps/files/src/filters/HiddenFilesFilter.ts +++ b/apps/files/src/filters/HiddenFilesFilter.ts @@ -15,7 +15,7 @@ class HiddenFilesFilter extends FileListFilter { constructor() { super('files:hidden', 0) - this.showHidden = loadState('files', 'config', { show_hidden: false }).show_hidden + this.showHidden = loadState>('files', 'config', { show_hidden: false }).show_hidden subscribe('files:config:updated', ({ key, value }) => { if (key === 'show_hidden') { diff --git a/apps/files/src/filters/TypeFilter.ts b/apps/files/src/filters/TypeFilter.ts index 3955805aa5e..94b109ea7a4 100644 --- a/apps/files/src/filters/TypeFilter.ts +++ b/apps/files/src/filters/TypeFilter.ts @@ -149,7 +149,12 @@ class TypeFilter extends FileListFilter { public setPresets(presets?: ITypePreset[]) { this.currentPresets = presets ?? [] - this.currentInstance!.$props.presets = presets + if (this.currentInstance !== undefined) { + // could be called before the instance was created + // (meaning the files list is not mounted yet) + this.currentInstance.$props.presets = presets + } + this.filterUpdated() const chips: IFileListFilterChip[] = []