Disable notifications on new 'reconnect' event for laptop resume
This commit is contained in:
@@ -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;
|
||||
|
||||
|
@@ -39,6 +39,12 @@ MessageReceiver.prototype.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
this.count = 0;
|
||||
if (this.hasConnected) {
|
||||
const ev = new Event('reconnect');
|
||||
this.dispatchEvent(ev);
|
||||
}
|
||||
|
||||
this.hasConnected = true;
|
||||
|
||||
if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
|
||||
|
Reference in New Issue
Block a user