Adding a quick check incase too many related tables - switch to just fetching everything.
This commit is contained in:
parent
7bd84bd048
commit
a8c96848a5
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue