settings: move schemaVersion definition to updateSetting

This commit is contained in:
dumbmoron 2024-07-13 12:32:08 +00:00
parent f4aff44004
commit 3f98f5bee8
No known key found for this signature in database

View file

@ -12,10 +12,7 @@ type PartialSettingsWithSchema = RecursivePartial<CobaltSettings> & { schemaVers
const writeToStorage = (settings: PartialSettings) => { const writeToStorage = (settings: PartialSettings) => {
localStorage.setItem( localStorage.setItem(
"settings", "settings",
JSON.stringify({ JSON.stringify(settings)
schemaVersion: defaultSettings.schemaVersion,
...settings
})
); );
return settings; return settings;
@ -65,7 +62,11 @@ export const storedSettings = readable<PartialSettings>(
export function updateSetting(partial: PartialSettings) { export function updateSetting(partial: PartialSettings) {
update((current) => { update((current) => {
const updated = writeToStorage( const updated = writeToStorage(
merge(current, partial) merge(
current,
partial,
{ schemaVersion: defaultSettings.schemaVersion }
)
); );
return updated; return updated;