Fix: Welten-Config — DB-Load bei jedem Login-Wechsel, einmalige localStorage→DB-Migration (SW by-v660)
This commit is contained in:
parent
71a13d695e
commit
7b8ee7e2b1
4 changed files with 22 additions and 15 deletions
|
|
@ -93,9 +93,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||||
<link rel="stylesheet" href="/css/design-system.css?v=659">
|
<link rel="stylesheet" href="/css/design-system.css?v=660">
|
||||||
<link rel="stylesheet" href="/css/layout.css?v=659">
|
<link rel="stylesheet" href="/css/layout.css?v=660">
|
||||||
<link rel="stylesheet" href="/css/components.css?v=659">
|
<link rel="stylesheet" href="/css/components.css?v=660">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
@ -562,7 +562,7 @@
|
||||||
<script src="/js/api.js?v=94"></script>
|
<script src="/js/api.js?v=94"></script>
|
||||||
<script src="/js/ui.js?v=94"></script>
|
<script src="/js/ui.js?v=94"></script>
|
||||||
<script src="/js/app.js?v=94"></script>
|
<script src="/js/app.js?v=94"></script>
|
||||||
<script src="/js/worlds.js?v=659"></script>
|
<script src="/js/worlds.js?v=660"></script>
|
||||||
|
|
||||||
<!-- Feature-Seiten werden lazy geladen -->
|
<!-- Feature-Seiten werden lazy geladen -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '659'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '660'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
const APP_VERSION = '1.3.0'; // ← semantische Version, wird bei make release gesetzt
|
const APP_VERSION = '1.3.0'; // ← semantische Version, wird bei make release gesetzt
|
||||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,6 @@ window.Worlds = (() => {
|
||||||
_setupButtons();
|
_setupButtons();
|
||||||
_goTo(_cur, false);
|
_goTo(_cur, false);
|
||||||
show();
|
show();
|
||||||
// Config aus DB laden (async, dann neu rendern wenn nötig)
|
|
||||||
await _loadConfigFromServer();
|
|
||||||
// Welten parallel rendern
|
|
||||||
_renderJetzt();
|
|
||||||
_renderHund();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(worldIdx) {
|
function show(worldIdx) {
|
||||||
|
|
@ -68,14 +63,19 @@ window.Worlds = (() => {
|
||||||
if (worldIdx != null) _goTo(worldIdx, false);
|
if (worldIdx != null) _goTo(worldIdx, false);
|
||||||
if (_cur === 2 && !_weltInited) { _weltInited = true; _renderWelt(); }
|
if (_cur === 2 && !_weltInited) { _weltInited = true; _renderWelt(); }
|
||||||
|
|
||||||
// Nach Login/Logout neu rendern
|
// Nach Login/Logout: Config aus DB laden, dann rendern
|
||||||
const currentUserId = _state?.user?.id ?? null;
|
const currentUserId = _state?.user?.id ?? null;
|
||||||
if (currentUserId !== _lastUserId) {
|
if (currentUserId !== _lastUserId) {
|
||||||
_lastUserId = currentUserId;
|
_lastUserId = currentUserId;
|
||||||
|
if (currentUserId) {
|
||||||
|
_loadConfigFromServer().then(() => { _renderJetzt(); _renderHund(); });
|
||||||
|
} else {
|
||||||
|
_cfgCache = null;
|
||||||
_renderJetzt();
|
_renderJetzt();
|
||||||
_renderHund();
|
_renderHund();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
const ov = document.getElementById('worlds-overlay');
|
const ov = document.getElementById('worlds-overlay');
|
||||||
|
|
@ -323,8 +323,15 @@ window.Worlds = (() => {
|
||||||
try { localStorage.setItem('world_chips', JSON.stringify(_cfgCache)); } catch {}
|
try { localStorage.setItem('world_chips', JSON.stringify(_cfgCache)); } catch {}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Noch nichts in DB: lokale Config hochladen (einmalige Migration)
|
||||||
|
const local = (() => { try { return JSON.parse(localStorage.getItem('world_chips') || 'null'); } catch { return null; } })();
|
||||||
|
if (local) {
|
||||||
|
_cfgCache = local;
|
||||||
|
API.put('/profile/world-config', { config: local }).catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
// Fallback: localStorage
|
// Fallback: localStorage → Default
|
||||||
try { _cfgCache = JSON.parse(localStorage.getItem('world_chips') || 'null') || _DEFAULT_CONFIG; }
|
try { _cfgCache = JSON.parse(localStorage.getItem('world_chips') || 'null') || _DEFAULT_CONFIG; }
|
||||||
catch { _cfgCache = _DEFAULT_CONFIG; }
|
catch { _cfgCache = _DEFAULT_CONFIG; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v659';
|
const CACHE_VERSION = 'by-v660';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue