Skip to content

Commit

Permalink
fix: refresh problems, display old values
Browse files Browse the repository at this point in the history
  • Loading branch information
lexoyo committed Mar 27, 2024
1 parent 267fdfa commit f36805d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/model/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,21 @@ export function getState(component: Component, id: StateId, exported: boolean =
export function setState(component: Component, id: StateId, state: StoredState, exported: boolean = true): void {
const key = exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY
const states = component.get(key) as StoredStateWithId[] ?? []
component.set(key, [
...states.filter(s => s.id !== id),
{
const existing = states.find(s => s.id === id) ?? null
if(existing) {
component.set(key, states.map(s => s.id !== id ? s : {
id,
...state,
}
])
}))
} else {
component.set(key, [
...states,
{
id,
...state,
}
])
}
fireChange({
label: state.label,
hidden: state.hidden,
Expand Down

0 comments on commit f36805d

Please sign in to comment.