Misc fixes and additions
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
This commit is contained in:
parent
724d70e58b
commit
02eefdac0e
9 changed files with 311 additions and 65 deletions
|
|
@ -24,16 +24,33 @@ export default function SettingsPage() {
|
|||
loadSettings();
|
||||
}, []);
|
||||
|
||||
function applyTheme(theme: string) {
|
||||
if (theme === 'light') {
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
document.documentElement.style.setProperty('color-scheme', 'light');
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.style.setProperty('color-scheme', 'dark');
|
||||
}
|
||||
localStorage.setItem('theme', theme);
|
||||
}
|
||||
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const data = await api.getSettings();
|
||||
setSettings({
|
||||
theme: data.theme || 'dark',
|
||||
thumbnail_images: data.thumbnail_images || 'true',
|
||||
thumbnail_videos: data.thumbnail_videos || 'true',
|
||||
max_versions: data.max_versions || '1',
|
||||
trash_auto_purge_days: data.trash_auto_purge_days || '14',
|
||||
});
|
||||
const s = data.settings || data;
|
||||
const loaded = {
|
||||
theme: s.theme || 'dark',
|
||||
thumbnail_images: s.thumbnail_images || 'true',
|
||||
thumbnail_videos: s.thumbnail_videos || 'true',
|
||||
max_versions: s.max_versions || '1',
|
||||
trash_auto_purge_days: s.trash_auto_purge_days || '14',
|
||||
};
|
||||
setSettings(loaded);
|
||||
// Apply the persisted theme on load
|
||||
applyTheme(loaded.theme);
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Failed to load settings');
|
||||
} finally {
|
||||
|
|
@ -51,17 +68,7 @@ export default function SettingsPage() {
|
|||
await api.updateSettings(settings);
|
||||
setSuccess(true);
|
||||
setTimeout(() => setSuccess(false), 3000);
|
||||
|
||||
// Update local theme variable if changed
|
||||
if (settings.theme === 'light') {
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
document.documentElement.style.setProperty('color-scheme', 'light');
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.style.setProperty('color-scheme', 'dark');
|
||||
}
|
||||
applyTheme(settings.theme);
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Failed to save settings');
|
||||
} finally {
|
||||
|
|
|
|||
Reference in a new issue