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>
|
||||
|
||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=659">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=659">
|
||||
<link rel="stylesheet" href="/css/components.css?v=659">
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=660">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=660">
|
||||
<link rel="stylesheet" href="/css/components.css?v=660">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -562,7 +562,7 @@
|
|||
<script src="/js/api.js?v=94"></script>
|
||||
<script src="/js/ui.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 -->
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
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 IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
|
||||
|
|
|
|||
|
|
@ -49,11 +49,6 @@ window.Worlds = (() => {
|
|||
_setupButtons();
|
||||
_goTo(_cur, false);
|
||||
show();
|
||||
// Config aus DB laden (async, dann neu rendern wenn nötig)
|
||||
await _loadConfigFromServer();
|
||||
// Welten parallel rendern
|
||||
_renderJetzt();
|
||||
_renderHund();
|
||||
}
|
||||
|
||||
function show(worldIdx) {
|
||||
|
|
@ -68,12 +63,17 @@ window.Worlds = (() => {
|
|||
if (worldIdx != null) _goTo(worldIdx, false);
|
||||
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;
|
||||
if (currentUserId !== _lastUserId) {
|
||||
_lastUserId = currentUserId;
|
||||
_renderJetzt();
|
||||
_renderHund();
|
||||
if (currentUserId) {
|
||||
_loadConfigFromServer().then(() => { _renderJetzt(); _renderHund(); });
|
||||
} else {
|
||||
_cfgCache = null;
|
||||
_renderJetzt();
|
||||
_renderHund();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,8 +323,15 @@ window.Worlds = (() => {
|
|||
try { localStorage.setItem('world_chips', JSON.stringify(_cfgCache)); } catch {}
|
||||
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 {}
|
||||
// Fallback: localStorage
|
||||
// Fallback: localStorage → Default
|
||||
try { _cfgCache = JSON.parse(localStorage.getItem('world_chips') || 'null') || _DEFAULT_CONFIG; }
|
||||
catch { _cfgCache = _DEFAULT_CONFIG; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Offline-Cache + Push Notifications + Tile-Cache
|
||||
============================================================ */
|
||||
|
||||
const CACHE_VERSION = 'by-v659';
|
||||
const CACHE_VERSION = 'by-v660';
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue