Skip to content

Commit

Permalink
fix after duplicate both states are linked
Browse files Browse the repository at this point in the history
  • Loading branch information
lexoyo committed Mar 27, 2024
1 parent 1de2624 commit 3580df5
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/model/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,13 @@ 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[] ?? []
const existing = states.find(s => s.id === id) ?? null
if(existing) {
existing.label = state.label
existing.hidden = state.hidden
existing.expression = state.expression
} else {
component.set(key, [
...states,
{
id,
...state,
}
])
}
component.set(key, [
...states.filter(s => s.id !== id),
{
id,
...state,
}
])
fireChange({
label: state.label,
hidden: state.hidden,
Expand Down

0 comments on commit 3580df5

Please sign in to comment.