Skip to content

Commit

Permalink
feat(js): Store the selected state in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
etu committed Mar 30, 2024
1 parent 4c777a7 commit b102b11
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const App = () => {
// Store state for the server list
const serverListState = van.state([])

// TODO: Store this in local session or URL or something.
const selectedServerState = van.state(null)
// Store state for selected server in the UI.
const selectedServerState = van.state(localStorage.getItem('selectedServerState') ?? null)

// Save the selected server state to local storage when it's updated.
van.derive(() => {
localStorage.setItem('selectedServerState', selectedServerState.val)
});

// This loads the current configured servers and their running state, then it updates
// the serverListState to update the rendered list.
Expand Down

0 comments on commit b102b11

Please sign in to comment.