Disable notifications on new 'reconnect' event for laptop resume

This commit is contained in:
Scott Nonnenberg 2018-07-03 14:56:30 -07:00
parent e83e10a7d1
commit a40a39314a
2 changed files with 14 additions and 0 deletions

View file

@ -368,6 +368,7 @@
messageReceiver.addEventListener('verified', onVerified);
messageReceiver.addEventListener('error', onError);
messageReceiver.addEventListener('empty', onEmpty);
messageReceiver.addEventListener('reconnect', onReconnect);
messageReceiver.addEventListener('progress', onProgress);
messageReceiver.addEventListener('configuration', onConfiguration);
@ -460,6 +461,13 @@
Whisper.Notifications.enable();
}
function onReconnect() {
// We disable notifications on first connect, but the same applies to reconnect. In
// scenarios where we're coming back from sleep, we can get offline/online events
// very fast, and it looks like a network blip. But we need to suppress
// notifications in these scenarios too. So we listen for 'reconnect' events.
Whisper.Notifications.disable();
}
function onProgress(ev) {
const { count } = ev;