Skip to content

Commit

Permalink
feat: idle syncing (#269)
Browse files Browse the repository at this point in the history
* init background syncing

* satisfy linter

* listener logs

* less noisy logging
  • Loading branch information
TalDerei authored Jan 24, 2025
1 parent 48245aa commit 0a6edc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"matches": ["<all_urls>"]
}
],
"permissions": ["storage", "unlimitedStorage", "offscreen"],
"permissions": ["storage", "unlimitedStorage", "offscreen", "alarms"],
"host_permissions": ["<all_urls>"],
"externally_connectable": {
"matches": ["<all_urls>"]
Expand Down
14 changes: 14 additions & 0 deletions apps/extension/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ const handler = await backOff(() => initHandler(), {
});

CRSessionManager.init(PRAX, handler);

// https://developer.chrome.com/docs/extensions/reference/api/alarms
void chrome.alarms.create('blockSync', {
periodInMinutes: 30,
delayInMinutes: 0,
});

chrome.alarms.onAlarm.addListener(alarm => {
if (alarm.name === 'blockSync') {
if (globalThis.__DEV__) {
console.info('Background sync scheduled');
}
}
});

0 comments on commit 0a6edc7

Please sign in to comment.