From 49a3d90dc5c6def01fa7081c106de96cb56afbc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tollk=C3=BChn?= Date: Tue, 3 Nov 2026 11:06:50 +0100 Subject: [PATCH] Scope localStorage keys per app directory localStorage is scoped per origin, not per path. Multiple jitsi-launch instances on one origin (e.g. meet.bnvb.eu/i and /p) therefore shared one language and one theme setting, and changing it in one instance changed it in all others. Prefix the language and theme keys with the app directory derived from the page path. Each instance keeps its own state; a root deployment gets the "/" prefix and behaves as before. Previously saved choices reset once because the key names change. --- assets/launch.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/assets/launch.js b/assets/launch.js index f27a78f..3c7cec4 100644 --- a/assets/launch.js +++ b/assets/launch.js @@ -12,6 +12,20 @@ let CONFIG = {}; const CONFIG_URL = "assets/config.json"; +/* + * localStorage is scoped per origin, not per path. + * Prefix keys with the app directory so parallel + * instances (e.g. meet.bnvb.eu/i and /p) stay + * independent. + * + * "/p/launch.html" becomes "/p/" + */ +const STORAGE_PREFIX = + window.location.pathname.replace(/[^/]*$/, ""); + +const LANGUAGE_KEY = STORAGE_PREFIX + "jitsiLauncherLanguage"; +const THEME_KEY = STORAGE_PREFIX + "jitsiLauncherTheme"; + /* ============================================================ * Translations * ============================================================ @@ -34,7 +48,7 @@ function detectLanguage() { * Saved language choice takes precedence. */ try { - const saved = localStorage.getItem("jitsiLauncherLanguage"); + const saved = localStorage.getItem(LANGUAGE_KEY); if (saved && TRANSLATIONS[saved]) { return saved; @@ -179,7 +193,7 @@ function setLanguage(language) { translation = TRANSLATIONS[language]; try { - localStorage.setItem("jitsiLauncherLanguage", language); + localStorage.setItem(LANGUAGE_KEY, language); } catch (error) { /* * localStorage can be blocked, e.g. in private mode. @@ -225,8 +239,6 @@ function closeNavMenu() { * ============================================================ */ -const THEME_KEY = "jitsiLauncherTheme"; - function savedTheme() { try { const saved = localStorage.getItem(THEME_KEY);