Fix stale data overwriting new data when requests are slow
This commit is contained in:
parent
0f56ed3c95
commit
b612c32ce5
|
@ -29,9 +29,18 @@
|
||||||
$: {
|
$: {
|
||||||
if ($views.selected?.name?.startsWith("all_")) {
|
if ($views.selected?.name?.startsWith("all_")) {
|
||||||
loading = true
|
loading = true
|
||||||
|
const loadingTableId = $tables.selected?._id
|
||||||
api.fetchDataForView($views.selected).then(rows => {
|
api.fetchDataForView($views.selected).then(rows => {
|
||||||
data = rows || []
|
|
||||||
loading = false
|
loading = false
|
||||||
|
|
||||||
|
// If we started a slow request then quickly change table, sometimes
|
||||||
|
// the old data overwrites the new data.
|
||||||
|
// This check ensures that we don't do that.
|
||||||
|
if (loadingTableId !== $tables.selected?._id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data = rows || []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue