Wait until table schema loads before searching to avoid initial double search

This commit is contained in:
Andrew Kingston 2021-05-13 13:11:45 +01:00
parent 8d46cc60fe
commit d82cd0e4af
1 changed files with 18 additions and 9 deletions

View File

@ -17,6 +17,7 @@
// Loading flag for the initial load
let loaded = false
let schemaLoaded = false
// Provider state
let rows = []
@ -31,7 +32,11 @@
$: hasPrevPage = pageNumber > 0
$: getSchema(dataSource)
$: sortType = getSortType(schema, sortColumn)
$: fetchData(
$: {
// Wait until schema loads before loading data, so that we can determine
// the correct sort type first time
if (schemaLoaded) {
fetchData(
dataSource,
query,
limit,
@ -40,7 +45,10 @@
sortType,
paginate
)
}
}
$: {
// Sort and limit rows in memory when we aren't searching internal tables
if (internalTable) {
rows = allRows
} else {
@ -195,6 +203,7 @@
}
})
schema = fixedSchema
schemaLoaded = true
}
const nextPage = async () => {