From 7c845be5a35267df20c386fc2a6db392a7152edd Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Wed, 15 May 2024 15:02:03 +0800 Subject: [PATCH] fix user setting migration issue --- src/models/settings.ts | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/models/settings.ts b/src/models/settings.ts index afa6e4db..0421dcb8 100644 --- a/src/models/settings.ts +++ b/src/models/settings.ts @@ -68,7 +68,6 @@ export class UserSettings { for (const key in data) { if ( - key in [ "autofill", "driveEncrypted", @@ -79,19 +78,35 @@ export class UserSettings { "oneDriveBusiness", "oneDriveEncrypted", "oneDriveRevoked", - "highContrast", "smartFilter", "enableContextMenu", - ] + ].includes(key) ) { - data[key] = data[key] === "true"; - } else if (key in ["autolock", "lastRemindingBackupTime", "offset", "zoom"]) { - data[key] = Number(data[key]); - } else if (key in ["advisorIgnoreList"]) { - data[key] = JSON.parse(data[key]); + settings[ + key as + | "autofill" + | "driveEncrypted" + | "driveRevoked" + | "dropboxEncrypted" + | "dropboxRevoked" + | "enableContextMenu" + | "oneDriveBusiness" + | "oneDriveEncrypted" + | "oneDriveRevoked" + | "smartFilter" + | "enableContextMenu" + ] = data[key] === "true"; + } else if ( + ["autolock", "lastRemindingBackupTime", "offset", "zoom"].includes(key) + ) { + settings[ + key as "autolock" | "lastRemindingBackupTime" | "offset" | "zoom" + ] = Number(data[key]); + } else if (["advisorIgnoreList"].includes(key)) { + settings[key as "advisorIgnoreList"] = JSON.parse(data[key]); + } else { + settings[key as keyof UserSettingsData] = data[key]; } - - settings[key as keyof UserSettingsData] = data[key]; } settings.storageLocation = location;