persistency mismatch

This commit is contained in:
2026-07-16 22:13:11 +02:00
parent 91125372c8
commit 29d144920a

View File

@@ -549,7 +549,17 @@ window.cancelAnimFrame = (function () {
img.src = randomImg; img.src = randomImg;
}; };
// Initialize active mode: prefer mode cookie, then session, then legacy mode-btn // Initialize active mode.
// For logged-in users, the server's f0ckSession.mode (sourced from user_options DB) is the
// authoritative cross-device truth. A stale local `mode` cookie from a previous session on
// this device could disagree (e.g. PC had ALL, mobile set SFW — PC cookie still says 3).
// Fix: prefer f0ckSession.mode when logged in and reconcile the local cookie to match.
// For guests: fall back to cookie (no session = cookie is the only persistence).
if (window.f0ckSession && window.f0ckSession.logged_in && window.f0ckSession.mode !== undefined) {
window.activeMode = +window.f0ckSession.mode;
// Reconcile the local cookie so future reads are consistent on this device
document.cookie = `mode=${window.activeMode}; Path=/; Max-Age=31536000`;
} else {
const _modeCookieRaw = document.cookie.split('; ').find(r => r.startsWith('mode=')); const _modeCookieRaw = document.cookie.split('; ').find(r => r.startsWith('mode='));
if (_modeCookieRaw) { if (_modeCookieRaw) {
window.activeMode = +_modeCookieRaw.split('=')[1]; window.activeMode = +_modeCookieRaw.split('=')[1];
@@ -563,6 +573,7 @@ window.cancelAnimFrame = (function () {
if (modeMatch) window.activeMode = +modeMatch[1]; if (modeMatch) window.activeMode = +modeMatch[1];
} }
} }
}
// Track active mode on <html> for notification thumbnail blur. // Track active mode on <html> for notification thumbnail blur.
// data-notif-filter is set to the current mode string and also // data-notif-filter is set to the current mode string and also