This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { writable, get } from "svelte/store" | ||
|
||
export const settings = writable( | ||
localStorage.settings | ||
? JSON.parse(localStorage.settings) | ||
: { | ||
security: { | ||
requireAuthentication: null, | ||
password: null, | ||
key: null, | ||
}, | ||
} | ||
) | ||
|
||
settings.subscribe((data) => { | ||
console.log("Settings changed: ", data) | ||
|
||
localStorage.setItem("settings", JSON.stringify(data)) | ||
}) | ||
|
||
export const getSettings = (): LibSettings => { | ||
return get(settings) | ||
} | ||
|
||
export const setSettings = (newSettings: LibSettings) => { | ||
settings.set(newSettings) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
import { writable } from "svelte/store" | ||
import { writable, get } from "svelte/store" | ||
|
||
export const state = writable({ | ||
importData: null, | ||
export const state = writable( | ||
sessionStorage.state | ||
? JSON.parse(sessionStorage.state) | ||
: { | ||
authenticated: false, | ||
importData: null, | ||
} | ||
) | ||
|
||
state.subscribe((data) => { | ||
console.log("State changed: ", data) | ||
|
||
sessionStorage.setItem("state", JSON.stringify(data)) | ||
}) | ||
|
||
export const getState = (): LibState => { | ||
return get(state) | ||
} | ||
|
||
export const setState = (newState: LibState) => { | ||
state.set(newState) | ||
} |