Skip to content

Commit

Permalink
Merge pull request #2967
Browse files Browse the repository at this point in the history
Add workaround for when we fail to read from extension storage.
  • Loading branch information
ghostwords committed May 31, 2024
2 parents 8d852ae + d82f8af commit 59c6250
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ function BadgerPen(callback) {

// initialize from extension local storage
chrome.storage.local.get(self.KEYS, function (store) {
let storage_err;
if (chrome.runtime.lastError) {
storage_err = chrome.runtime.lastError.message;
}

self.KEYS.forEach(key => {
if (utils.hasOwn(store, key)) {
if (store && utils.hasOwn(store, key)) {
self[key] = new BadgerStorage(key, store[key]);
} else {
let storageObj = new BadgerStorage(key, {});
Expand All @@ -94,6 +99,14 @@ function BadgerPen(callback) {
}
});

if (!store || storage_err) {
console.error("Error reading from extension storage:", storage_err);
if (!store) {
self.settings_map.setItem("showIntroPage", false);
self.settings_map.setItem("seenComic", true);
}
}

badger.initSettings();

if (!chrome.storage.managed) {
Expand Down

0 comments on commit 59c6250

Please sign in to comment.