Skip to content

Commit 6f2c492

Browse files
authored
Merge pull request #1216 from Authenticator-Extension/try-to-fix-undefined-issue
Try to prevent issues if chrome.storage.get unexpectedly returns undefined
2 parents 5e8df8e + 12f8291 commit 6f2c492

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run-tests:
4343
runs-on: ubuntu-latest
4444
name: Run tests
45-
needs: [ build ]
45+
needs: [build]
4646

4747
steps:
4848
- uses: actions/checkout@v2
@@ -53,9 +53,9 @@ jobs:
5353
- name: Install dependencies
5454
run: npm ci
5555
env:
56-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
56+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
5757

5858
- name: Test code
59-
uses: mujo-code/puppeteer-headful@master
59+
uses: mymindstorm/puppeteer-headful@8f745c770f7f4c0f9f332d7c43a775f90e53779a
6060
with:
6161
args: npm test

src/models/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class UserSettings {
153153
? StorageLocation.Local
154154
: storageLocation;
155155
const storageData: UserSettingsData =
156-
(await chrome.storage[location].get("UserSettings")).UserSettings || {};
156+
(await chrome.storage[location].get("UserSettings"))?.UserSettings || {};
157157
delete storageData[key];
158158

159159
UserSettings.items = storageData;
@@ -163,7 +163,7 @@ export class UserSettings {
163163

164164
private static async getStorageData(location: StorageLocation) {
165165
const storageData: UserSettingsData =
166-
(await chrome.storage[location].get("UserSettings")).UserSettings || {};
166+
(await chrome.storage[location].get("UserSettings"))?.UserSettings || {};
167167

168168
return storageData;
169169
}

src/store/Accounts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,10 @@ export class Accounts implements Module {
480480
newStorageLocation === StorageLocation.Sync
481481
) {
482482
const localData = await chrome.storage.local.get();
483-
delete localData.UserSettings;
484-
await chrome.storage.sync.set(localData);
483+
if (localData?.UserSettings) {
484+
delete localData.UserSettings;
485+
await chrome.storage.sync.set(localData);
486+
}
485487
const syncData = await chrome.storage.sync.get();
486488

487489
// Double check if data was set

0 commit comments

Comments
 (0)