Первая постановка на уведомления

This commit is contained in:
mi
2026-07-26 13:20:23 +03:00
parent 8c3c454998
commit 8822ae609f
15 changed files with 698 additions and 271 deletions
+15 -3
View File
@@ -2,13 +2,25 @@ export type AuthStatus = 'authenticated' | 'guest' | null;
const KEY = 'han_auth_status';
function safeGet(key: string): string | null {
try { return localStorage.getItem(key); } catch { return null; }
}
function safeSet(key: string, value: string) {
try { localStorage.setItem(key, value); } catch { /* ignore */ }
}
function safeRemove(key: string) {
try { localStorage.removeItem(key); } catch { /* ignore */ }
}
export function getAuthStatus(): AuthStatus {
return (localStorage.getItem(KEY) as AuthStatus) ?? null;
return (safeGet(KEY) as AuthStatus) ?? null;
}
export function setAuthStatus(status: AuthStatus) {
if (status === null) localStorage.removeItem(KEY);
else localStorage.setItem(KEY, status);
if (status === null) safeRemove(KEY);
else safeSet(KEY, status);
}
export function isGuest() {