Browse Source

fix(gui): within watch verify view belongs to the table or not

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3977/head
Pranav C 2 years ago
parent
commit
2c63324d9c
  1. 10
      packages/nc-gui/composables/useViewColumns.ts

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

@ -205,11 +205,13 @@ export function useViewColumns(
?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[] ?.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( watch(
() => view?.value?.id, [() => view?.value?.id, () => meta.value?.columns?.length],
async (newVal) => { async ([newViewId]) => {
if (newVal) { // reload only if view belongs to current table
if (newViewId && view.value?.fk_model_id === meta.value?.id) {
await loadViewColumns() await loadViewColumns()
} }
}, },

Loading…
Cancel
Save