0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-02-18 01:24:26 -05:00

fix(web): map settings (#15375)

This commit is contained in:
Jason Rasmussen 2025-01-16 10:05:14 -05:00 committed by GitHub
parent 6ce1533117
commit 89f40b311c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,7 +62,7 @@ export interface MapSettings {
dateBefore: string;
}
export const mapSettings = persisted<MapSettings>('map-settings', {
const defaultMapSettings = {
allowDarkMode: true,
includeArchived: false,
onlyFavorites: false,
@ -71,7 +71,17 @@ export const mapSettings = persisted<MapSettings>('map-settings', {
relativeDate: '',
dateAfter: '',
dateBefore: '',
});
};
const persistedObject = <T>(key: string, defaults: T) =>
persisted<T>(key, defaults, {
serializer: {
parse: (text) => ({ ...defaultMapSettings, ...JSON.parse(text ?? null) }),
stringify: JSON.stringify,
},
});
export const mapSettings = persistedObject<MapSettings>('map-settings', defaultMapSettings);
export const videoViewerVolume = persisted<number>('video-viewer-volume', 1, {});
export const videoViewerMuted = persisted<boolean>('video-viewer-muted', false, {});