From 2c63324d9c35472dd9c9c9d21f8279e7800f5deb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 8 Oct 2022 12:24:05 +0530 Subject: [PATCH] fix(gui): within watch verify view belongs to the table or not Signed-off-by: Pranav C --- packages/nc-gui/composables/useViewColumns.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts index ed7b4f0dad..0922527003 100644 --- a/packages/nc-gui/composables/useViewColumns.ts +++ b/packages/nc-gui/composables/useViewColumns.ts @@ -205,11 +205,13 @@ export function useViewColumns( ?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[] }) - // reload view columns when table meta changes + // reload view columns when active view changes + // or when columns count changes(delete/add) watch( - () => view?.value?.id, - async (newVal) => { - if (newVal) { + [() => view?.value?.id, () => meta.value?.columns?.length], + async ([newViewId]) => { + // reload only if view belongs to current table + if (newViewId && view.value?.fk_model_id === meta.value?.id) { await loadViewColumns() } },