feat: Added light mode plus various bug fixes
- Added click handler for Easter egg that enables music inspiration feature. - Updated credits page to include new icons and handle click events. - Enhanced inspiration page to fetch and display Spotify track embed HTML. - Refactored inspiration loading logic to include track data. - Introduced theme selection in settings with light and dark modes. - Updated settings page to reflect new theme options and improve toast messages. - Refined layout styles across various pages for consistent theming. - Bumped application version to 1.5.0 in installer script.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { browser } from "$app/environment";
|
||||
import type { EMLy_GUI_Settings } from "$lib/types";
|
||||
import { getFromLocalStorage, saveToLocalStorage } from "$lib/utils/localStorageHelper";
|
||||
import { applyTheme, getStoredTheme } from "$lib/utils/theme";
|
||||
import { setLocale } from "$lib/paraglide/runtime";
|
||||
|
||||
const STORAGE_KEY = "emly_gui_settings";
|
||||
|
||||
@@ -11,7 +13,9 @@ const defaults: EMLy_GUI_Settings = {
|
||||
previewFileSupportedTypes: ["jpg", "jpeg", "png"],
|
||||
enableAttachedDebuggerProtection: true,
|
||||
useDarkEmailViewer: true,
|
||||
enableUpdateChecker: true,
|
||||
enableUpdateChecker: false,
|
||||
musicInspirationEnabled: false,
|
||||
theme: "dark",
|
||||
};
|
||||
|
||||
class SettingsStore {
|
||||
@@ -33,6 +37,37 @@ class SettingsStore {
|
||||
console.error("Failed to load settings", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Migration: Check for legacy musicInspirationEnabled key
|
||||
const legacyMusic = getFromLocalStorage("musicInspirationEnabled");
|
||||
if (legacyMusic !== null) {
|
||||
this.settings.musicInspirationEnabled = legacyMusic === "true";
|
||||
localStorage.removeItem("musicInspirationEnabled");
|
||||
this.save(); // Save immediately to persist the migration
|
||||
}
|
||||
|
||||
// Sync theme from localStorage key used in app.html
|
||||
const storedTheme = getStoredTheme();
|
||||
if (!this.settings.theme) {
|
||||
this.settings.theme = storedTheme;
|
||||
} else if (this.settings.theme !== storedTheme) {
|
||||
// If there's a mismatch, prioritize the theme from emly_theme key
|
||||
this.settings.theme = storedTheme;
|
||||
}
|
||||
|
||||
// Apply the theme
|
||||
applyTheme(this.settings.theme);
|
||||
|
||||
// Apply the language
|
||||
if (this.settings.selectedLanguage) {
|
||||
setLocale(this.settings.selectedLanguage);
|
||||
}
|
||||
|
||||
// Save defaults/merged settings to storage if they didn't exist or were updated during load
|
||||
if (!stored) {
|
||||
this.save();
|
||||
}
|
||||
|
||||
this.hasHydrated = true;
|
||||
}
|
||||
|
||||
@@ -43,11 +78,20 @@ class SettingsStore {
|
||||
|
||||
update(newSettings: Partial<EMLy_GUI_Settings>) {
|
||||
this.settings = { ...this.settings, ...newSettings };
|
||||
|
||||
// Apply theme if it changed
|
||||
if (newSettings.theme && this.settings.theme) {
|
||||
applyTheme(this.settings.theme);
|
||||
}
|
||||
|
||||
this.save();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.settings = { ...defaults };
|
||||
if (this.settings.theme) {
|
||||
applyTheme(this.settings.theme);
|
||||
}
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user