Adding a quick check incase too many related tables - switch to just fetching everything.

This commit is contained in:
mike12345567 2023-09-26 17:13:16 +01:00
parent 7bd84bd048
commit a8c96848a5
1 changed files with 8 additions and 3 deletions

View File

@ -81,13 +81,18 @@ export function createTablesStore() {
replaceTable(savedTable._id, savedTable) replaceTable(savedTable._id, savedTable)
select(savedTable._id) select(savedTable._id)
// make sure tables up to date (related) // make sure tables up to date (related)
const tableUpdates = [] const tableIdsToFetch = []
for (let column of Object.values(updatedTable?.schema || {})) { for (let column of Object.values(updatedTable?.schema || {})) {
if (column.type === FIELDS.LINK.type) { 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 return savedTable
} }