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 <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2025-02-20 12:56:19 +01:00
parent 87813cd647
commit a673547397
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
2 changed files with 7 additions and 2 deletions

View file

@ -15,7 +15,7 @@ class HiddenFilesFilter extends FileListFilter {
constructor() {
super('files:hidden', 0)
this.showHidden = loadState<UserConfig>('files', 'config', { show_hidden: false }).show_hidden
this.showHidden = loadState<Partial<UserConfig>>('files', 'config', { show_hidden: false }).show_hidden
subscribe('files:config:updated', ({ key, value }) => {
if (key === 'show_hidden') {

View file

@ -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[] = []