From b102b1177772e837043928afabdf0b235ada4f68 Mon Sep 17 00:00:00 2001 From: Elis Hirwing Date: Sat, 30 Mar 2024 21:13:20 +0100 Subject: [PATCH] feat(js): Store the selected state in localStorage --- static/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/script.js b/static/script.js index 7a35432..82730b8 100644 --- a/static/script.js +++ b/static/script.js @@ -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.