Reset rows and tick before updating schema when swapping table ID in grids
This commit is contained in:
parent
05bba92b94
commit
194a135183
|
@ -121,13 +121,22 @@ export const deriveStores = context => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Subscribe to changes of this fetch model
|
// Subscribe to changes of this fetch model
|
||||||
unsubscribe = newFetch.subscribe($fetch => {
|
unsubscribe = newFetch.subscribe(async $fetch => {
|
||||||
if ($fetch.loaded && !$fetch.loading) {
|
if ($fetch.loaded && !$fetch.loading) {
|
||||||
hasNextPage.set($fetch.hasNextPage)
|
hasNextPage.set($fetch.hasNextPage)
|
||||||
const $instanceLoaded = get(instanceLoaded)
|
const $instanceLoaded = get(instanceLoaded)
|
||||||
const resetRows = $fetch.resetKey !== lastResetKey
|
const resetRows = $fetch.resetKey !== lastResetKey
|
||||||
|
const previousResetKey = lastResetKey
|
||||||
lastResetKey = $fetch.resetKey
|
lastResetKey = $fetch.resetKey
|
||||||
|
|
||||||
|
// If resetting rows due to a table change, wipe data and wait for
|
||||||
|
// derived stores to compute. This prevents stale data being passed
|
||||||
|
// to cells when we save the new schema.
|
||||||
|
if (!$instanceLoaded && previousResetKey) {
|
||||||
|
rows.set([])
|
||||||
|
await tick()
|
||||||
|
}
|
||||||
|
|
||||||
// Reset state properties when dataset changes
|
// Reset state properties when dataset changes
|
||||||
if (!$instanceLoaded || resetRows) {
|
if (!$instanceLoaded || resetRows) {
|
||||||
table.set($fetch.definition)
|
table.set($fetch.definition)
|
||||||
|
|
Loading…
Reference in New Issue