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) => {
|
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;
|
||||||
|
|
Loading…
Reference in a new issue