blob: c72472a45b28a963717adaa3b7aa89e419dc4eb0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import { browser } from "$app/environment";
import { writable } from "svelte/store";
const persistSession = (key, defaultValue = undefined) => {
const s = writable(
browser &&
sessionStorage.getItem(key) &&
sessionStorage.getItem(key) !== "undefined"
? JSON.parse(sessionStorage.getItem(key) || "")
: defaultValue,
);
s.subscribe((v) => {
browser && sessionStorage.setItem(key, JSON.stringify(v));
});
return s;
};
const persistLocal = (key, defaultValue: any = undefined) => {
const s = writable(
browser &&
localStorage.getItem(key) &&
localStorage.getItem(key) !== "undefined"
? JSON.parse(localStorage.getItem(key) || "")
: defaultValue,
);
s.subscribe((v) => {
try {
browser && localStorage.setItem(key, JSON.stringify(v));
} catch (e) {
console.log("problem setting key", v);
console.log(e);
}
});
return s;
};
export const account = writable();
export const amountPrompt = persistLocal("amountPrompt");
export const avatar = writable();
export const banner = writable();
export const event = writable();
export const events = writable({});
export const installPrompt = writable();
export const invoice = writable();
export const last = writable();
export const loginRedirect = writable();
export const decrypted = persistLocal("decrypted", {});
export const mnemonic = persistSession("mnemonic");
export const newPayment = persistLocal("newPayment");
export const password = writable<string | undefined>();
export const passwordPrompt = writable();
export const pin = persistLocal("pin");
export const rate = writable();
export const request = writable();
export const requestRedirect = writable();
export const theme = persistLocal("light");
export const token = persistSession("token");
export const ndef = writable();
export const showQr = persistLocal("showQr", true);
|