siftlode/frontend/src/lib/hints.ts
npeter83 472aba6480 refactor(frontend): adopt store/storage helpers; centralize persistence
- errorDialog + hints now use createStore (drop their bespoke listener arrays).
- theme/sidebarLayout/notifications/App filters/Playlists plSort use readMerged/
  readJSON/writeJSON instead of inline try/JSON.parse/catch.
- Stats, SettingsPanel and App's channel filter/view tabs use usePersistedState
  (the 3 sites that reinvented usePersistedTab inline).
- Every siftlode.* key now sourced from the LS registry (no scattered literals).
2026-06-26 03:30:19 +02:00

27 lines
758 B
TypeScript

// App-wide "hints" toggle: when on, Tooltip components reveal short explanatory
// captions on hover so the UI is somewhat self-documenting for new users. Experienced
// users can turn it off in Settings. Persisted to localStorage (+ server preferences).
import { createStore } from "./store";
import { LS } from "./storage";
function load(): boolean {
try {
return localStorage.getItem(LS.hints) !== "0"; // default ON
} catch {
return true;
}
}
const store = createStore<boolean>(load());
export const hintsEnabled = store.get;
export const subscribeHints = store.subscribe;
export function setHintsEnabled(v: boolean): void {
store.set(v);
try {
localStorage.setItem(LS.hints, v ? "1" : "0");
} catch {
/* ignore */
}
}