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)
watch(
() => activeView?.value,
async (view) => {
if (view?.id) {
() => activeView?.value?.id,
async (viewId) => {
if (viewId) {
await loadFilters()
filtersLength.value = filters.value.length || 0
}

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

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

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

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

Loading…
Cancel
Save