Feature: App-Einstellungen in DB (preferred_theme neu, notes_ki+gassi_stunde schon drin) — geräteübergreifend sync (SW by-v785)
This commit is contained in:
parent
2ff6d4dfe4
commit
e8cf742911
8 changed files with 41 additions and 20 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '784'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '785'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||
|
|
@ -529,6 +529,9 @@ const App = (() => {
|
|||
navigate('onboarding');
|
||||
}
|
||||
|
||||
// Theme aus DB-Profil übernehmen (überschreibt localStorage-Wert)
|
||||
_applyUserTheme(state.user);
|
||||
|
||||
// Drei Welten nach Login starten (falls noch nicht initialisiert)
|
||||
if (window.Worlds) window.Worlds.init(state);
|
||||
|
||||
|
|
@ -607,6 +610,15 @@ const App = (() => {
|
|||
navigate('welcome', false);
|
||||
}
|
||||
|
||||
function _applyUserTheme(user) {
|
||||
const theme = user?.preferred_theme;
|
||||
if (!theme || theme === 'system') return; // System-Einstellung: nichts tun
|
||||
localStorage.setItem('by_theme', theme);
|
||||
const html = document.documentElement;
|
||||
if (theme === 'dark') html.setAttribute('data-theme', 'dark');
|
||||
else if (theme === 'light') html.setAttribute('data-theme', 'light');
|
||||
}
|
||||
|
||||
function _showVerifyBanner() {
|
||||
const banner = document.getElementById('verify-banner');
|
||||
if (!banner) return;
|
||||
|
|
|
|||
|
|
@ -315,9 +315,9 @@ window.Page_settings = (() => {
|
|||
font-size:var(--text-sm);
|
||||
font-family:inherit;
|
||||
cursor:pointer">
|
||||
<option value="system" ${(localStorage.getItem('by_theme')||'system') === 'system' ? 'selected' : ''}>System</option>
|
||||
<option value="light" ${localStorage.getItem('by_theme') === 'light' ? 'selected' : ''}>Hell</option>
|
||||
<option value="dark" ${localStorage.getItem('by_theme') === 'dark' ? 'selected' : ''}>Dunkel</option>
|
||||
<option value="system" ${(u.preferred_theme||localStorage.getItem('by_theme')||'system') === 'system' ? 'selected' : ''}>System</option>
|
||||
<option value="light" ${(u.preferred_theme||localStorage.getItem('by_theme')) === 'light' ? 'selected' : ''}>Hell</option>
|
||||
<option value="dark" ${(u.preferred_theme||localStorage.getItem('by_theme')) === 'dark' ? 'selected' : ''}>Dunkel</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
@ -849,22 +849,22 @@ window.Page_settings = (() => {
|
|||
}
|
||||
});
|
||||
|
||||
document.getElementById('select-theme')?.addEventListener('change', e => {
|
||||
document.getElementById('select-theme')?.addEventListener('change', async e => {
|
||||
const val = e.target.value;
|
||||
localStorage.setItem('by_theme', val);
|
||||
localStorage.setItem('by_theme', val); // lokaler Cache für schnellen Start
|
||||
const html = document.documentElement;
|
||||
if (val === 'dark') {
|
||||
html.setAttribute('data-theme', 'dark');
|
||||
} else if (val === 'light') {
|
||||
html.setAttribute('data-theme', 'light');
|
||||
} else {
|
||||
html.removeAttribute('data-theme');
|
||||
}
|
||||
if (val === 'dark') html.setAttribute('data-theme', 'dark');
|
||||
else if (val === 'light') html.setAttribute('data-theme', 'light');
|
||||
else html.removeAttribute('data-theme');
|
||||
UI.toast.info(
|
||||
val === 'dark' ? 'Dark Mode aktiviert.' :
|
||||
val === 'light' ? 'Hell-Modus aktiviert.' :
|
||||
'Theme folgt der Systemeinstellung.'
|
||||
);
|
||||
try {
|
||||
await API.patch('/profile', { preferred_theme: val });
|
||||
if (_appState?.user) _appState.user.preferred_theme = val;
|
||||
} catch { /* ignorieren — localStorage-Fallback greift */ }
|
||||
});
|
||||
|
||||
document.getElementById('toggle-pocket-mode')?.addEventListener('change', e => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue