Files
bookhoard/web/src/storage.ts
T
john-okeefe ea5ad7a41b feat(web): update frontend TypeScript modules and API types
This commit updates the web frontend TypeScript modules:

Core modules:
- admin.ts: Admin panel functionality and user management
- analytics.ts: Analytics dashboard and data visualization
- api-explorer.ts: Interactive API documentation explorer
- api.ts: Core API client with request/response handling
- collections.ts: Book collection management UI
- conflicts.ts: Sync conflict resolution interface
- custom-section-builder.ts: Dynamic section builder for UI
- docs.ts: Documentation viewer and navigation
- dom.ts: DOM manipulation utilities and helpers
- header.ts: Application header with navigation
- library.ts: Library view and book grid management
- linking.ts: Device-book linking interface
- password_validation.ts: Client-side password strength validation
- queue.ts: Device sync queue management UI
- search.ts: Full-text search with Lunr integration
- storage.ts: Local storage and cache management
- theme.ts: Theme management and CSS variable updates
- themeDropdown.ts: Theme selector dropdown component
- toast.ts: Toast notification system
- woodPaneling.ts: Visual theme effects
- woodPanelingInit.ts: Visual effects initialization

Type definitions:
- api.d.ts: Updated TypeScript definitions for API responses

These updates enhance the frontend with improved functionality
for book management, device synchronization, and user experience.
2026-02-27 17:06:48 -05:00

84 lines
1.6 KiB
TypeScript

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 | null {
return localStorage.getItem("selectedLibrary");
}
function setSelectedLibrary(libraryId: string): void {
localStorage.setItem("selectedLibrary", libraryId);
}
function getSelectedBook(): string | null {
return localStorage.getItem("selectedBook");
}
function setSelectedBook(bookId: string): void {
localStorage.setItem("selectedBook", bookId);
}
function clearAll(): void {
localStorage.clear();
}
(window as any).storage = {
getToken,
setToken,
removeToken,
getRefreshToken,
setRefreshToken,
removeRefreshToken,
getTheme,
setTheme,
getSelectedLibrary,
setSelectedLibrary,
getSelectedBook,
setSelectedBook,
clearAll,
};
export {
getToken,
setToken,
removeToken,
getRefreshToken,
setRefreshToken,
removeRefreshToken,
getTheme,
setTheme,
getSelectedLibrary,
setSelectedLibrary,
getSelectedBook,
setSelectedBook,
clearAll,
};