Add misc settings + misc cleanup

This commit is contained in:
ZXY101
2024-01-13 17:53:21 +02:00
parent c817cc8681
commit 28201f5d88
7 changed files with 111 additions and 14 deletions

View File

@@ -1,2 +1,3 @@
export * from './volume-data'
export * from './settings'
export * from './settings'
export * from './misc'

33
src/lib/settings/misc.ts Normal file
View File

@@ -0,0 +1,33 @@
import { browser } from '$app/environment';
import { writable } from 'svelte/store';
export type MiscSettings = {
galleryLayout: 'grid' | 'list';
gallerySorting: 'ASC' | 'DESC';
};
export type MiscSettingsKey = keyof MiscSettings;
const defaultSettings: MiscSettings = {
galleryLayout: 'grid',
gallerySorting: 'ASC',
}
const stored = browser ? window.localStorage.getItem('miscSettings') : undefined;
export const miscSettings = writable<MiscSettings>(stored ? JSON.parse(stored) : defaultSettings);
miscSettings.subscribe((miscSettings) => {
if (browser) {
window.localStorage.setItem('miscSettings', JSON.stringify(miscSettings));
}
});
export function updateMiscSetting(key: MiscSettingsKey, value: any) {
miscSettings.update((miscSettings) => {
return {
...miscSettings,
[key]: value
};
});
}

View File

@@ -1,5 +1,4 @@
import { browser } from '$app/environment';
import { zoomDefault } from '$lib/panzoom';
import { derived, get, writable } from 'svelte/store';
export type FontSize =