1
0
Fork 0
mirror of synced 2024-09-28 15:21:28 +12:00

Prevent flashed while sorting

This commit is contained in:
Adria Navarro 2024-09-27 11:02:00 +02:00
parent 3e294c3cb9
commit 64f4497c76

View file

@ -120,17 +120,22 @@ export const initialise = context => {
// When sorting changes, ensure view definition is kept up to date
unsubscribers.push(
sort.subscribe(async $sort => {
// If we can mutate schema then update the view definition
if (get(config).canSaveSchema) {
// Ensure we're updating the correct view
const $view = get(definition)
if ($view?.id !== $datasource.id) {
return
}
// Skip if nothing actually changed
if (
$sort?.column !== $view.sort?.field ||
$sort?.order !== $view.sort?.order
$sort?.column === $view.sort?.field &&
$sort?.order === $view.sort?.order
) {
return
}
// If we can mutate schema then update the view definition
if (get(config).canSaveSchema) {
await datasource.actions.saveDefinition({
...$view,
sort: {
@ -139,7 +144,6 @@ export const initialise = context => {
},
})
}
}
// Also update the fetch to ensure the new sort is respected.
// Ensure we're updating the correct fetch.