Browse Source

fix(gui-v2): merge any missing default values with localstorage

- this to avoid missing properties when adding new state variables

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3037/head
Pranav C 2 years ago
parent
commit
f0fff78f15
  1. 6
      packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilterMenu.vue
  2. 2
      packages/nc-gui-v2/composables/useGlobal/state.ts
  3. 2
      packages/nc-gui-v2/composables/useGlobal/types.ts

6
packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilterMenu.vue

@ -19,7 +19,8 @@ const filtersLength = ref(0)
const autosave = computed({
get() {
return $state.filterAutoSave.value
}, set(value: boolean) {
},
set(value: boolean) {
$state.filterAutoSave.value = value
},
})
@ -52,8 +53,7 @@ const applyChanges = async () => {
@update:filters-length="filtersLength = $event"
>
<div class="d-flex align-end mt-2 min-h-[30px]" @click.stop>
<a-checkbox id="col-filter-checkbox" v-model:checked="autosave" class="col-filter-checkbox" hide-details
dense>
<a-checkbox id="col-filter-checkbox" v-model:checked="autosave" class="col-filter-checkbox" hide-details dense>
<span class="text-grey text-xs">
{{ $t('msg.info.filterAutoApply') }}
<!-- Auto apply -->

2
packages/nc-gui-v2/composables/useGlobal/state.ts

@ -60,7 +60,7 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
}
/** saves a reactive state, any change to these values will write/delete to localStorage */
const storage = useStorage<StoredState>(storageKey, initialState)
const storage = useStorage<StoredState>(storageKey, initialState, localStorage, { mergeDefaults: true })
/** force turn off of dark mode, regardless of previously stored settings */
storage.value.darkMode = false

2
packages/nc-gui-v2/composables/useGlobal/types.ts

@ -17,7 +17,7 @@ export interface StoredState {
lang: string
darkMode: boolean
feedbackForm: FeedbackForm
filterAutoSave :boolean
filterAutoSave: boolean
}
export type State = ToRefs<Omit<StoredState, 'token'>> & {

Loading…
Cancel
Save