Prevent unnecessary store updates

This commit is contained in:
Andrew Kingston 2024-06-20 13:12:59 +01:00
parent 337b1189ec
commit 0f3decd127
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { derived, get } from "svelte/store" import { derived } from "svelte/store"
export const initialise = context => { export const initialise = context => {
const { scrolledRowCount, rows, visualRowCapacity } = context const { scrolledRowCount, rows, visualRowCapacity } = context

View File

@ -569,10 +569,12 @@ export const initialise = context => {
// Wipe the row change cache when changing row // Wipe the row change cache when changing row
previousFocusedRowId.subscribe(id => { previousFocusedRowId.subscribe(id => {
if (id && !get(inProgressChanges)[id]) { if (id && !get(inProgressChanges)[id]) {
rowChangeCache.update(state => { if (Object.keys(get(rowChangeCache)[id] || {}).length) {
delete state[id] rowChangeCache.update(state => {
return state delete state[id]
}) return state
})
}
} }
}) })