diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 4eb1f962f0..a99081de13 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -307,12 +307,6 @@ dispatch("updatecolumns") gridDispatch("close-edit-column") - if (saveColumn.type === LINK_TYPE) { - // Fetching the new tables - tables.fetch() - // Fetching the new relationships - datasources.fetch() - } if (originalName) { notifications.success("Column updated successfully") } else { @@ -339,11 +333,6 @@ confirmDeleteDialog.hide() dispatch("updatecolumns") gridDispatch("close-edit-column") - - if (editableColumn.type === LINK_TYPE) { - // Updating the relationships - datasources.fetch() - } } } catch (error) { notifications.error(`Error deleting column: ${error.message}`) diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js index 457a58fdbb..51b8416eda 100644 --- a/packages/builder/src/stores/backend/tables.js +++ b/packages/builder/src/stores/backend/tables.js @@ -81,13 +81,21 @@ export function createTablesStore() { replaceTable(savedTable._id, savedTable) select(savedTable._id) // make sure tables up to date (related) - let tableIdsToFetch = [] + let newTableIds = [] for (let column of Object.values(updatedTable?.schema || {})) { if (column.type === FIELDS.LINK.type) { - tableIdsToFetch.push(column.tableId) + newTableIds.push(column.tableId) } } - tableIdsToFetch = [...new Set(tableIdsToFetch)] + + let oldTableIds = [] + for (let column of Object.values(oldTable?.schema || {})) { + if (column.type === FIELDS.LINK.type) { + oldTableIds.push(column.tableId) + } + } + + const tableIdsToFetch = [...new Set([...newTableIds, ...oldTableIds])] // too many tables to fetch, just get all if (tableIdsToFetch.length > 3) { await fetch()