20 lines
501 B
TypeScript
20 lines
501 B
TypeScript
import { PREF } from "./const";
|
|
|
|
export function addBoughtHint(id: number) {
|
|
const hints = getBoughtHints();
|
|
if (hints.includes(id)) {
|
|
return;
|
|
}
|
|
hints.push(id);
|
|
localStorage.setItem(PREF.boughtHints, JSON.stringify(hints));
|
|
window.dispatchEvent(new Event('storage'));
|
|
}
|
|
|
|
export function getBoughtHints(): number[] {
|
|
const hintsList = localStorage.getItem(PREF.boughtHints);
|
|
if (hintsList === null) {
|
|
return [];
|
|
}
|
|
return JSON.parse(hintsList);
|
|
}
|