Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comments, refactor #36

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Prism from "svelte-prism";
import makePKCE from "./utils/pkce.js";

let onMountDone = false;
let readFromLocalStorage = false;
let darkMode = false;

const scopes = {
Expand Down Expand Up @@ -87,8 +87,10 @@
onMount(() => {
if(!getStatesFromLocalStorage()) {
//states not found in local storage, save default states to local storage
states = states; //triggers saveStatesToLocalStorage
const _states = JSON.stringify(states);
localStorage.setItem("states", _states);
}
readFromLocalStorage = true;

processFragmentOrQuery();
updateFavicon();
Expand Down Expand Up @@ -145,8 +147,6 @@
darkMode = false;
}
});

onMountDone = true;
});

const navLinks = [
Expand Down Expand Up @@ -498,7 +498,12 @@
}

function saveStatesToLocalStorage() {
if (!onMountDone) return;
if (!readFromLocalStorage) {
//only update states in localStorage after reading from it on onMount
//if not, states gets reset on every page load (we need to update on existing localstorage state)
return;
}

const _states = JSON.stringify(states);
localStorage.setItem("states", _states);
}
Expand Down
Loading