mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
settings: move schemaVersion definition to updateSetting
This commit is contained in:
parent
f4aff44004
commit
3f98f5bee8
1 changed files with 6 additions and 5 deletions
|
@ -12,10 +12,7 @@ type PartialSettingsWithSchema = RecursivePartial<CobaltSettings> & { schemaVers
|
|||
const writeToStorage = (settings: PartialSettings) => {
|
||||
localStorage.setItem(
|
||||
"settings",
|
||||
JSON.stringify({
|
||||
schemaVersion: defaultSettings.schemaVersion,
|
||||
...settings
|
||||
})
|
||||
JSON.stringify(settings)
|
||||
);
|
||||
|
||||
return settings;
|
||||
|
@ -65,7 +62,11 @@ export const storedSettings = readable<PartialSettings>(
|
|||
export function updateSetting(partial: PartialSettings) {
|
||||
update((current) => {
|
||||
const updated = writeToStorage(
|
||||
merge(current, partial)
|
||||
merge(
|
||||
current,
|
||||
partial,
|
||||
{ schemaVersion: defaultSettings.schemaVersion }
|
||||
)
|
||||
);
|
||||
|
||||
return updated;
|
||||
|
|
Loading…
Reference in a new issue