Skip to content

Commit

Permalink
Merge pull request #1216 from Authenticator-Extension/try-to-fix-unde…
Browse files Browse the repository at this point in the history
…fined-issue

Try to prevent issues if chrome.storage.get unexpectedly returns undefined
  • Loading branch information
mymindstorm authored Jun 29, 2024
2 parents 5e8df8e + 12f8291 commit 6f2c492
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run-tests:
runs-on: ubuntu-latest
name: Run tests
needs: [ build ]
needs: [build]

steps:
- uses: actions/checkout@v2
Expand All @@ -53,9 +53,9 @@ jobs:
- name: Install dependencies
run: npm ci
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"

- name: Test code
uses: mujo-code/puppeteer-headful@master
uses: mymindstorm/puppeteer-headful@8f745c770f7f4c0f9f332d7c43a775f90e53779a
with:
args: npm test
4 changes: 2 additions & 2 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/store/Accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6f2c492

Please sign in to comment.