Skip to content

Commit

Permalink
fix: file system filters reactivity
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Oct 4, 2023
1 parent d27aa03 commit 5734323
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
}
set filters (value: FileFilterType[]) {
this.$store.dispatch('config/saveByPath', {
path: `uiSettings.fileSystem.activeFilters.${this.currentRoot}`,
value,
server: true
})
this.$store.dispatch('config/updateFileSystemActiveFilters', { root: this.currentRoot, value })
}
// Maintains content menu state.
Expand Down
6 changes: 6 additions & 0 deletions src/store/config/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SocketActions } from '@/api/socketActions'
import { loadLocaleMessagesAsync, getStartingLocale } from '@/plugins/i18n'
import { Waits } from '@/globals'
import { AppTableHeader } from '@/types'
import { FileFilterType } from '../files/types'

export const actions: ActionTree<ConfigState, RootState> = {
/**
Expand Down Expand Up @@ -142,6 +143,11 @@ export const actions: ActionTree<ConfigState, RootState> = {
SocketActions.serverWrite('uiSettings.dashboard.tempPresets', state.uiSettings.dashboard.tempPresets)
},

async updateFileSystemActiveFilters ({ commit, state }, payload: { root: string, value: FileFilterType[] }) {
commit('setFileSystemActiveFilters', payload)
SocketActions.serverWrite(`uiSettings.fileSystem.activeFilters.${payload.root}`, state.uiSettings.fileSystem.activeFilters[payload.root])
},

/**
* Toggle a tables header state based on its name and key.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/store/config/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { merge, set } from 'lodash-es'
import { v4 as uuidv4 } from 'uuid'
import { AppTableHeader } from '@/types'
import { AppTablePartialHeader } from '@/types/tableheaders'
import { FileFilterType } from '../files/types'

export const mutations: MutationTree<ConfigState> = {
/**
Expand Down Expand Up @@ -37,6 +38,10 @@ export const mutations: MutationTree<ConfigState> = {
Vue.set(processed.editor, 'autoEditExtensions', payload.editor.autoEditExtensions)
}

if (payload.fileSystem && payload.fileSystem.activeFilters) {
Vue.set(processed.fileSystem, 'activeFilters', payload.fileSystem.activeFilters)
}

Vue.set(state, 'uiSettings', processed)
}
},
Expand Down Expand Up @@ -154,6 +159,10 @@ export const mutations: MutationTree<ConfigState> = {
state.uiSettings.dashboard.tempPresets.splice(i, 1)
},

setFileSystemActiveFilters (state, payload: { root: string, value: FileFilterType[] }) {
Vue.set(state.uiSettings.fileSystem.activeFilters, payload.root, payload.value)
},

/**
* Puts us into layout mode
*/
Expand Down
6 changes: 1 addition & 5 deletions src/store/config/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ export const defaultState = (): ConfigState => {
}
},
fileSystem: {
activeFilters: {
gcodes: [],
config: [],
logs: []
}
activeFilters: {}
},
toolhead: {
forceMove: false,
Expand Down
2 changes: 1 addition & 1 deletion src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,5 @@ export interface GcodePreviewConfig {
}

export interface FileSystemConfig {
activeFilters: Partial<Record<string, FileFilterType[]>>
activeFilters: Record<string, FileFilterType[]>
}

0 comments on commit 5734323

Please sign in to comment.