Browse Source

fix(gui): avoid duplicate watch and only trigger when active view id changes

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3977/head
Pranav C 2 years ago
parent
commit
833781c998
  1. 6
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
  2. 10
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  3. 6
      packages/nc-gui/composables/useViewColumns.ts

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

@ -41,9 +41,9 @@ const { filters, loadFilters } = useViewFilters(
const filtersLength = ref(0) const filtersLength = ref(0)
watch( watch(
() => activeView?.value, () => activeView?.value?.id,
async (view) => { async (viewId) => {
if (view?.id) { if (viewId) {
await loadFilters() await loadFilters()
filtersLength.value = filters.value.length || 0 filtersLength.value = filters.value.length || 0
} }

10
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -48,16 +48,6 @@ const {
metaColumnById, metaColumnById,
} = useViewColumns(activeView, meta, () => reloadDataHook.trigger()) } = useViewColumns(activeView, meta, () => reloadDataHook.trigger())
watch(
() => activeView.value?.id,
async (newVal, oldVal) => {
if (newVal && newVal !== oldVal && meta.value) {
await loadViewColumns()
}
},
{ immediate: true },
)
watch( watch(
sortedAndFilteredFields, sortedAndFilteredFields,
(v) => { (v) => {

6
packages/nc-gui/composables/useViewColumns.ts

@ -206,11 +206,11 @@ export function useViewColumns(
}) })
// reload view columns when table meta changes // reload view columns when table meta changes
watch(meta, async (newVal, oldVal) => { watch(() => view?.value?.id, async (newVal) => {
if (newVal !== oldVal && newVal) { if (newVal) {
await loadViewColumns() await loadViewColumns()
} }
}) }, { immediate: true })
return { return {
fields, fields,

Loading…
Cancel
Save