2021-05-26 12:43:11 -04:00
|
|
|
const PREFIX = "gamja_";
|
|
|
|
|
|
|
|
function getItem(k) {
|
|
|
|
k = PREFIX + k;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function setItem(k, v) {
|
|
|
|
k = PREFIX + k;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Item {
|
|
|
|
constructor(k) {
|
|
|
|
this.k = PREFIX + k;
|
|
|
|
}
|
|
|
|
|
|
|
|
load() {
|
2021-06-10 12:11:11 -04:00
|
|
|
let v = localStorage.getItem(this.k);
|
2021-05-26 12:43:11 -04:00
|
|
|
if (!v) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return JSON.parse(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
put(v) {
|
|
|
|
if (v) {
|
|
|
|
localStorage.setItem(this.k, JSON.stringify(v));
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem(this.k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const autoconnect = new Item("autoconnect");
|
|
|
|
|
|
|
|
const rawReceipts = new Item("receipts");
|
|
|
|
|
|
|
|
export const receipts = {
|
|
|
|
load() {
|
2021-06-10 12:11:11 -04:00
|
|
|
let v = rawReceipts.load();
|
2021-05-26 12:43:11 -04:00
|
|
|
return new Map(Object.entries(v || {}));
|
|
|
|
},
|
|
|
|
put(m) {
|
|
|
|
rawReceipts.put(Object.fromEntries(m));
|
|
|
|
},
|
|
|
|
};
|