Files
bookhoard/web/src/storage.ts
T
john-okeefe 5ac407057e
Release / build-and-push (push) Successful in 2m24s
fix(search): link results to book detail page and add cover thumbnails
Search results navigated to /bookshelf with no filters instead of the
selected book's page. Results now link to /media/:id and display cover
thumbnails, with cover URLs resolved server-side via ResolveMediaURL.
Removes the dead selectedBook localStorage plumbing.
2026-07-30 14:55:00 -04:00

66 lines
1.4 KiB
TypeScript

const ALL_LIBRARIES = "__all__";
function getToken(): string | null {
return localStorage.getItem("token");
}
function setToken(token: string): void {
localStorage.setItem("token", token);
}
function removeToken(): void {
localStorage.removeItem("token");
}
function getRefreshToken(): string | null {
return localStorage.getItem("refresh_token");
}
function setRefreshToken(token: string): void {
localStorage.setItem("refresh_token", token);
}
function removeRefreshToken(): void {
localStorage.removeItem("refresh_token");
}
function getTheme(): string {
return localStorage.getItem("theme") || "tokyo-night";
}
function setTheme(theme: string): void {
localStorage.setItem("theme", theme);
}
function getSelectedLibrary(): string {
const stored = localStorage.getItem("selectedLibrary");
if (stored === ALL_LIBRARIES) return "";
if (stored) return stored;
return "";
}
function setSelectedLibrary(libraryId: string): void {
const value = libraryId === "" ? ALL_LIBRARIES : libraryId;
localStorage.setItem("selectedLibrary", value);
document.cookie = `selectedLibrary=${encodeURIComponent(value)};path=/;max-age=${365 * 24 * 60 * 60};samesite=lax`;
}
function clearAll(): void {
localStorage.clear();
}
export {
ALL_LIBRARIES,
clearAll,
getRefreshToken,
getSelectedLibrary,
getTheme,
getToken,
removeRefreshToken,
removeToken,
setRefreshToken,
setSelectedLibrary,
setTheme,
setToken
};