Skip to content

Commit

Permalink
feat(background): Adds a helper method to refresh the toolbar upon in…
Browse files Browse the repository at this point in the history
…stallation.
  • Loading branch information
ERosendo committed Apr 2, 2024
1 parent ec54aea commit 82050c6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
exportInstance(Notifier);
exportInstance(Recap);

function saveOptionsAndUpdateToolbar(options) {
chrome.storage.local.set({ options: options }, function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
updateToolbarButton(tabs[0]);
});
});
}

function setDefaultOptions(details) {
// Set options to their default values.
console.debug('RECAP: Setting default options after install/upgrade.');
Expand All @@ -22,7 +30,7 @@ function setDefaultOptions(details) {
};
if ($.isEmptyObject(items)) {
console.debug('RECAP: New install. Attempting to set defaults.');
chrome.storage.local.set({options: defaults});
saveOptionsAndUpdateToolbar(defaults)
console.debug('RECAP: Set the defaults on new install successfully.');
} else {
console.debug('RECAP: Existing install. Attempting to set new ' +
Expand Down Expand Up @@ -52,7 +60,7 @@ function setDefaultOptions(details) {
}
}
console.debug('RECAP: Persisting new settings object.');
chrome.storage.local.set({options: items.options});
saveOptionsAndUpdateToolbar(items.options)
}
});
}
Expand Down

0 comments on commit 82050c6

Please sign in to comment.