From a8c96848a5c443b00a014efce8e0ebafcfce5b41 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Sep 2023 17:13:16 +0100 Subject: [PATCH] Adding a quick check incase too many related tables - switch to just fetching everything. --- packages/builder/src/stores/backend/tables.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js index dae8674146..7e01e0d511 100644 --- a/packages/builder/src/stores/backend/tables.js +++ b/packages/builder/src/stores/backend/tables.js @@ -81,13 +81,18 @@ export function createTablesStore() { replaceTable(savedTable._id, savedTable) select(savedTable._id) // make sure tables up to date (related) - const tableUpdates = [] + const tableIdsToFetch = [] for (let column of Object.values(updatedTable?.schema || {})) { if (column.type === FIELDS.LINK.type) { - tableUpdates.push(singleFetch(column.tableId)) + tableIdsToFetch.push(column.tableId) } } - await Promise.all(tableUpdates) + // too many tables to fetch, just get all + if (tableIdsToFetch.length > 3) { + await fetch() + } else { + await Promise.all(tableIdsToFetch.map(id => singleFetch(id))) + } return savedTable }