From 5daac02ced5e994321adc35eb2cdc2536874e0b1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 7 Oct 2022 20:07:16 +0530 Subject: [PATCH] fix(api): avoid unnecessary filter reload Signed-off-by: Pranav C --- .../smartsheet/toolbar/ColumnFilterMenu.vue | 11 +++++++---- .../components/smartsheet/toolbar/FieldsMenu.vue | 2 +- .../components/smartsheet/toolbar/SortListMenu.vue | 4 ++-- packages/nc-gui/composables/useViewColumns.ts | 2 +- packages/nc-gui/composables/useViewFilters.ts | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue index 47b2356963..b23fa2bd13 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue @@ -42,9 +42,11 @@ const filtersLength = ref(0) watch( () => activeView?.value, - async () => { - await loadFilters() - filtersLength.value = filters.value.length || 0 + async (view) => { + if (view?.id) { + await loadFilters() + filtersLength.value = filters.value.length || 0 + } }, { immediate: true }, ) @@ -83,7 +85,8 @@ const filterAutoSaveLoc = computed({ @update:filters-length="filtersLength = $event" >
- + {{ $t('msg.info.filterAutoApply') }} diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue index f03944b4d1..581df98a31 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue @@ -51,7 +51,7 @@ const { watch( () => activeView.value?.id, async (newVal, oldVal) => { - if (newVal !== oldVal && meta.value) { + if (newVal && newVal !== oldVal && meta.value) { await loadViewColumns() } }, diff --git a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue index 1a35292606..3112d08d20 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue @@ -32,8 +32,8 @@ const columnByID = computed(() => watch( () => view.value?.id, - () => { - loadSorts() + (viewId) => { + if(viewId)loadSorts() }, { immediate: true }, ) diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts index 27e9e1641d..e97312d0bc 100644 --- a/packages/nc-gui/composables/useViewColumns.ts +++ b/packages/nc-gui/composables/useViewColumns.ts @@ -207,7 +207,7 @@ export function useViewColumns( // reload view columns when table meta changes watch(meta, async (newVal, oldVal) => { - if (newVal !== oldVal && meta.value) { + if (newVal !== oldVal && newVal) { await loadViewColumns() } }) diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts index 06098fdecb..8df90d85e8 100644 --- a/packages/nc-gui/composables/useViewFilters.ts +++ b/packages/nc-gui/composables/useViewFilters.ts @@ -218,7 +218,7 @@ export function useViewFilters( return metas?.value?.[view?.value?.fk_model_id as string]?.columns?.length || 0 }, async (nextColsLength, oldColsLength) => { - if (nextColsLength < oldColsLength) await loadFilters() + if (nextColsLength && nextColsLength < oldColsLength) await loadFilters() }, )