Wait until table schema loads before searching to avoid initial double search
This commit is contained in:
parent
8d46cc60fe
commit
d82cd0e4af
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
// Loading flag for the initial load
|
// Loading flag for the initial load
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
let schemaLoaded = false
|
||||||
|
|
||||||
// Provider state
|
// Provider state
|
||||||
let rows = []
|
let rows = []
|
||||||
|
@ -31,16 +32,23 @@
|
||||||
$: hasPrevPage = pageNumber > 0
|
$: hasPrevPage = pageNumber > 0
|
||||||
$: getSchema(dataSource)
|
$: getSchema(dataSource)
|
||||||
$: sortType = getSortType(schema, sortColumn)
|
$: sortType = getSortType(schema, sortColumn)
|
||||||
$: fetchData(
|
|
||||||
dataSource,
|
|
||||||
query,
|
|
||||||
limit,
|
|
||||||
sortColumn,
|
|
||||||
sortOrder,
|
|
||||||
sortType,
|
|
||||||
paginate
|
|
||||||
)
|
|
||||||
$: {
|
$: {
|
||||||
|
// Wait until schema loads before loading data, so that we can determine
|
||||||
|
// the correct sort type first time
|
||||||
|
if (schemaLoaded) {
|
||||||
|
fetchData(
|
||||||
|
dataSource,
|
||||||
|
query,
|
||||||
|
limit,
|
||||||
|
sortColumn,
|
||||||
|
sortOrder,
|
||||||
|
sortType,
|
||||||
|
paginate
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$: {
|
||||||
|
// Sort and limit rows in memory when we aren't searching internal tables
|
||||||
if (internalTable) {
|
if (internalTable) {
|
||||||
rows = allRows
|
rows = allRows
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,6 +203,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
schema = fixedSchema
|
schema = fixedSchema
|
||||||
|
schemaLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextPage = async () => {
|
const nextPage = async () => {
|
||||||
|
|
Loading…
Reference in New Issue