Add misc settings + misc cleanup
This commit is contained in:
@@ -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
33
src/lib/settings/misc.ts
Normal 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
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { zoomDefault } from '$lib/panzoom';
|
||||
import { derived, get, writable } from 'svelte/store';
|
||||
|
||||
export type FontSize =
|
||||
|
||||
Reference in New Issue
Block a user