Skip to content

Commit

Permalink
fix: load active item from storage if present (#174)
Browse files Browse the repository at this point in the history
We were doing this in the old redux model, but forgot to
implement since we moved the "active" state to the historySlice
rather than the stateSlice for easier manipulation and removing
thunks
  • Loading branch information
evan-buss authored Jul 1, 2024
1 parent fc95f6d commit fe3bc7f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/app/src/state/historySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ const loadState = (): HistoryItem[] => {
}
};

const loadActiveState = (): number | undefined => {
try {
return JSON.parse(localStorage.getItem("active")!);
} catch (err) {
return undefined;
}
};

const initialState: HistoryState = {
active: undefined,
active: loadActiveState(),
items: loadState()
};

Expand Down

0 comments on commit fe3bc7f

Please sign in to comment.