From 436b735d2ab879257c779027a9acde5c97ed1724 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sat, 13 Jul 2024 20:39:40 +0000 Subject: [PATCH] web/settings: try to migrate settings if new format is not used yet --- web/src/lib/state/settings.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/src/lib/state/settings.ts b/web/src/lib/state/settings.ts index 1b62b750..555c45a9 100644 --- a/web/src/lib/state/settings.ts +++ b/web/src/lib/state/settings.ts @@ -4,6 +4,7 @@ import { merge } from 'ts-deepmerge'; import type { RecursivePartial } from '../types/generic'; import type { CobaltSettings } from '../types/settings'; +import { migrateOldSettings } from '../settings/migrate'; import defaultSettings from '../settings/defaults'; type PartialSettings = RecursivePartial; @@ -43,6 +44,11 @@ const migrate = (settings: PartialSettingsWithSchema) => { const loadFromStorage = () => { const settings = localStorage.getItem('settings'); if (!settings) { + const migrated = migrateOldSettings(); + if (migrated) { + return writeToStorage(migrated); + } + return {}; }