Make the notifications download initial delay configurable
Background / User story
In MV3, the background page is replaced by a service worker. Service workers are meant to be event driven, and browsers may suspend them at any time. A common lifecycle for a service worker is that it is activated when an event it's listening for happens, it handles that event, and then after 30 seconds of being idle it is suspended again.
In the notifications module, notifications are downloaded from a remote server. This download currently hardcoded to wait for a minute after startup before doing any downloads. In MV3, this may result in downloads not happening when they are expected to happen.
const INITIAL_DELAY = 1 * MILLIS_IN_MINUTE;
What to change
- Development:
Make the initial delay configurable using prefs.
For example, this code comes from synchronizer.js, which had a similar problem:
let getPreferredMillis = (field, fallback) =>
field in Prefs ? Prefs[field] : fallback;
...
this._downloader.scheduleChecks(
getPreferredMillis("subscriptions_check_interval", CHECK_INTERVAL),
getPreferredMillis("subscriptions_initial_delay", INITIAL_DELAY)
);
- Documentation:
Make sure docs/prefs.md is updated with any new prefs.