Skip to content

Commit

Permalink
Add re-check and re-add for bg update timers.
Browse files Browse the repository at this point in the history
Not very useful in an ideal world but here we are.
  • Loading branch information
Sashank999 committed Jun 17, 2024
1 parent 59242b2 commit 9022fad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
5 changes: 4 additions & 1 deletion extension/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"logs": {
"features": [],
"fixes": [{ "message": "Fixed various TS features(Gym Graph, OC NNB, Profile Spies) not working.", "contributor": "TheFoxMan" }],
"changes": [{ "message": "Add option to force reset background update timers.", "contributor": "TheFoxMan" }],
"changes": [
{ "message": "Add option to force reset background update timers.", "contributor": "TheFoxMan" },
{ "message": "Add re-check and re-add for background update timers.", "contributor": "TheFoxMan" }
],
"removed": []
}
},
Expand Down
22 changes: 11 additions & 11 deletions extension/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ chrome.runtime.onStartup.addListener(async () => {
});
});

// Register updaters
// (async () => {
// const currentAlarms = await chrome.alarms.getAll();
// if (currentAlarms.length !== 4) {
// await chrome.alarms.clearAll();
// await chrome.alarms.create(ALARM_NAMES.NOTIFICATIONS, { periodInMinutes: 0.5 });
// await chrome.alarms.create(ALARM_NAMES.CLEAR_CACHE, { periodInMinutes: 60 });
// await chrome.alarms.create(ALARM_NAMES.CLEAR_USAGE, { periodInMinutes: 60 * 24 });
// await chrome.alarms.create(ALARM_NAMES.DATA_UPDATE, { periodInMinutes: 0.5 });
// }
// })();
// Register updaters, if not registered.
(async () => {
const currentAlarms = await chrome.alarms.getAll();
if (currentAlarms.length !== 4) {
await chrome.alarms.clearAll();
await chrome.alarms.create(ALARM_NAMES.NOTIFICATIONS, { periodInMinutes: 0.5 });
await chrome.alarms.create(ALARM_NAMES.CLEAR_CACHE, { periodInMinutes: 60 });
await chrome.alarms.create(ALARM_NAMES.CLEAR_USAGE, { periodInMinutes: 60 * 24 });
await chrome.alarms.create(ALARM_NAMES.DATA_UPDATE, { periodInMinutes: 0.5 });
}
})();

// On alarm triggered
chrome.alarms.onAlarm.addListener(async (alarm) => {
Expand Down

0 comments on commit 9022fad

Please sign in to comment.