- 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).
27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
import i18n from "../i18n";
|
|
import { createStore } from "./store";
|
|
|
|
// A single, self-explanatory error dialog (modal) the user must acknowledge — used when the
|
|
// server can't carry out an action (a definitive 4xx/5xx response). Distinct from toasts
|
|
// (transient, e.g. connection blips) and from silent handling. Module-level so the non-React
|
|
// api layer can raise it; an <ErrorDialog> mounted at the app root renders the current one.
|
|
export interface AppError {
|
|
title: string;
|
|
message: string;
|
|
}
|
|
|
|
const store = createStore<AppError | null>(null);
|
|
|
|
export function reportError(message?: string, title?: string): void {
|
|
store.set({
|
|
title: title || i18n.t("errors.title"),
|
|
message: message || i18n.t("errors.generic"),
|
|
});
|
|
}
|
|
|
|
export function dismissError(): void {
|
|
store.set(null);
|
|
}
|
|
|
|
export const subscribeError = store.subscribe;
|
|
export const getError = store.get;
|