mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/settings: try to migrate settings if new format is not used yet
This commit is contained in:
parent
5a630c2320
commit
436b735d2a
1 changed files with 6 additions and 0 deletions
|
@ -4,6 +4,7 @@ import { merge } from 'ts-deepmerge';
|
||||||
import type { RecursivePartial } from '../types/generic';
|
import type { RecursivePartial } from '../types/generic';
|
||||||
import type { CobaltSettings } from '../types/settings';
|
import type { CobaltSettings } from '../types/settings';
|
||||||
|
|
||||||
|
import { migrateOldSettings } from '../settings/migrate';
|
||||||
import defaultSettings from '../settings/defaults';
|
import defaultSettings from '../settings/defaults';
|
||||||
|
|
||||||
type PartialSettings = RecursivePartial<CobaltSettings>;
|
type PartialSettings = RecursivePartial<CobaltSettings>;
|
||||||
|
@ -43,6 +44,11 @@ const migrate = (settings: PartialSettingsWithSchema) => {
|
||||||
const loadFromStorage = () => {
|
const loadFromStorage = () => {
|
||||||
const settings = localStorage.getItem('settings');
|
const settings = localStorage.getItem('settings');
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
|
const migrated = migrateOldSettings();
|
||||||
|
if (migrated) {
|
||||||
|
return writeToStorage(migrated);
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue