diff --git a/src/models/settings.ts b/src/models/settings.ts index ae793e76..f40cb2e1 100644 --- a/src/models/settings.ts +++ b/src/models/settings.ts @@ -153,7 +153,7 @@ export class UserSettings { ? StorageLocation.Local : storageLocation; const storageData: UserSettingsData = - (await chrome.storage[location].get("UserSettings")).UserSettings || {}; + (await chrome.storage[location].get("UserSettings"))?.UserSettings || {}; delete storageData[key]; UserSettings.items = storageData; @@ -163,7 +163,7 @@ export class UserSettings { private static async getStorageData(location: StorageLocation) { const storageData: UserSettingsData = - (await chrome.storage[location].get("UserSettings")).UserSettings || {}; + (await chrome.storage[location].get("UserSettings"))?.UserSettings || {}; return storageData; } diff --git a/src/store/Accounts.ts b/src/store/Accounts.ts index 22c00b1a..2a6bd0bf 100644 --- a/src/store/Accounts.ts +++ b/src/store/Accounts.ts @@ -480,8 +480,10 @@ export class Accounts implements Module { newStorageLocation === StorageLocation.Sync ) { const localData = await chrome.storage.local.get(); - delete localData.UserSettings; - await chrome.storage.sync.set(localData); + if (localData?.UserSettings) { + delete localData.UserSettings; + await chrome.storage.sync.set(localData); + } const syncData = await chrome.storage.sync.get(); // Double check if data was set