refactor: item 29 cleanup

F16 F17 F18 F19 F20 F21: import polling backs off and pauses in a hidden tab, one date format module, fake timers in the import tests, error codes instead of raw messages, one safe storage wrapper, dead code.
This commit is contained in:
lobo committed 2026-09-30 15:00:47 +02:00
1 parent aa5832225d
commit 89d0b29698
31 files changed
+238 -81

No files matched your search

+5 -14
View File
@@ -1,4 +1,5 @@
import {apiFetch} from './api.js';
import {storage} from './storage.js';
export const LANGUAGES = ['en', 'de'];
@@ -6,23 +7,13 @@ const LANGUAGE_STORAGE_KEY = 'tbp_language';
export const REQUEST_TIMEOUT_MS = 10000;
export const readCachedLanguage = () => {
try {
const stored = localStorage.getItem(LANGUAGE_STORAGE_KEY);
return LANGUAGES.includes(stored) ? stored : null;
} catch {
return null;
}
const stored = storage.get(LANGUAGE_STORAGE_KEY);
return LANGUAGES.includes(stored) ? stored : null;
};
export const cacheLanguage = (language) => {
try {
localStorage.setItem(LANGUAGE_STORAGE_KEY, language);
} catch {
// Private mode or a full storage: the language is only not cached.
}
};
export const cacheLanguage = (language) => storage.set(LANGUAGE_STORAGE_KEY, language);
export const ME_URL = () => `${import.meta.env.VITE_API_URL}/api/users/me?v=1`;
export const ME_URL = () => `${import.meta.env.VITE_API_URL}/api/users/me`;
/**
* GET /api/users/me on Auth. The caller handles the response status.