PEE/src/stores.ts
2022-01-02 16:02:09 +01:00

23 lines
546 B
TypeScript

import { writable } from "svelte/store";
const localLoad = (key: string, def: any) =>
('__pee__' + key) in localStorage
? JSON.parse(localStorage.getItem('__pee__' + key)!)
: def;
const localSet = (key: string, value: any) =>
localStorage.setItem('__pee__' + key, JSON.stringify(value));
export const settings = writable(localLoad('settings', {
apv: false,
xpv: false,
xpi: false,
apa: false,
blacklist: [],
sources: []
}));
settings.subscribe(newVal => {
localSet('settings', newVal);
});