1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-24 20:52:44 +01:00
immich/web/src/lib/stores/preferences.store.ts
Michel Heusschen 9807f76aff
chore(web): improve type checking (#2644)
* fix(web): use id instead of assetId

* chore(web): improve type checking

* fix test jobs

* improve type checking and resolve errors
2023-06-02 08:55:08 -05:00

37 lines
1,007 B
TypeScript

import { browser } from '$app/environment';
import { persisted } from 'svelte-local-storage-store';
const initialTheme =
browser && !window.matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark';
// The 'color-theme' key is also used by app.html to prevent FOUC on page load.
export const colorTheme = persisted<'dark' | 'light'>('color-theme', initialTheme, {
serializer: {
parse: (text) => (text === 'light' ? text : 'dark'),
stringify: (obj) => obj
}
});
// Locale to use for formatting dates, numbers, etc.
export const locale = persisted<string | undefined>('locale', undefined, {
serializer: {
parse: (text) => text,
stringify: (obj) => obj ?? ''
}
});
export interface MapSettings {
allowDarkMode: boolean;
onlyFavorites: boolean;
relativeDate: string;
dateAfter: string;
dateBefore: string;
}
export const mapSettings = persisted<MapSettings>('map-settings', {
allowDarkMode: true,
onlyFavorites: false,
relativeDate: '',
dateAfter: '',
dateBefore: ''
});