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 => {
const { scrolledRowCount, rows, visualRowCapacity } = context

View File

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