Fix forced reload detection when tab is resumed after WebUI update

In case the tab gets resumed, it does not get fully reloaded but does reexecute js.
This caused the initial timestamp to get overwritten and lead to the forced reload detection to be incorrect, because it assumed that the app just got loaded.
This commit is contained in:
schroda
2025-11-04 23:29:17 +01:00
parent 7c1e4be0e8
commit 198d899b86
2 changed files with 7 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ const FORCED_REFRESH_THRESHOLD = d(30).seconds.inWholeMilliseconds;
const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp'; const INITIAL_LOAD_TIMESTAMP_KEY = 'webUIInitialLoadTimestamp';
AppStorage.session.setItem(INITIAL_LOAD_TIMESTAMP_KEY, Date.now()); AppStorage.session.setItemIfMissing(INITIAL_LOAD_TIMESTAMP_KEY, Date.now());
export const WebUIUpdateChecker = () => { export const WebUIUpdateChecker = () => {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@@ -63,6 +63,12 @@ export class Storage {
this.storage.setItem(key, valueToStore); this.storage.setItem(key, valueToStore);
fireEvent(valueToStore as string); fireEvent(valueToStore as string);
} }
setItemIfMissing(key: string, value: unknown, emitEvent?: boolean): void {
if (this.getItem(key) === null) {
this.setItem(key, value, emitEvent);
}
}
} }
export class AppStorage { export class AppStorage {