1
0
Fork 0
mirror of synced 2024-10-05 04:25:21 +13:00

Fix stale data overwriting new data when requests are slow

This commit is contained in:
Andrew Kingston 2021-04-13 15:10:49 +01:00
parent 0f56ed3c95
commit b612c32ce5

View file

@ -29,9 +29,18 @@
$: {
if ($views.selected?.name?.startsWith("all_")) {
loading = true
const loadingTableId = $tables.selected?._id
api.fetchDataForView($views.selected).then(rows => {
data = rows || []
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 || []
})
}
}