Merge pull request #924 from Bilb/enable-notifications

Enable back notifications
pull/933/head
Audric Ackermann 5 years ago committed by GitHub
commit f9c38d720f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1471,6 +1471,9 @@
};
Whisper.Notifications.disable(); // avoid notification flood until empty
setTimeout(() => {
Whisper.Notifications.enable();
}, window.CONSTANTS.NOTIFICATION_ENABLE_TIMEOUT_SECONDS * 1000);
if (Whisper.Registration.ongoingSecondaryDeviceRegistration()) {
const ourKey = textsecure.storage.user.getNumber();
@ -1643,6 +1646,11 @@
// 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();
// Enable back notifications once most messages have been fetched
setTimeout(() => {
Whisper.Notifications.enable();
}, window.CONSTANTS.NOTIFICATION_ENABLE_TIMEOUT_SECONDS * 1000);
}
function onProgress(ev) {
const { count } = ev;

@ -34,8 +34,6 @@
Whisper.Notifications = new (Backbone.Collection.extend({
initialize() {
this.isEnabled = false;
this.on('add', this.update);
this.on('remove', this.onRemove);
this.lastNotification = null;
@ -45,7 +43,11 @@
// and batches up the quick successive update() calls we get from an incoming
// read sync, which might have a number of messages referenced inside of it.
this.fastUpdate = this.update;
this.update = _.debounce(this.update, 1000);
this.update = _.debounce(this.update, 2000);
// make those calls use the debounced function
this.on('add', this.update);
this.on('remove', this.onRemove);
},
update() {
if (this.lastNotification) {

@ -70,6 +70,7 @@ window.CONSTANTS = {
MAX_MESSAGE_BODY_LENGTH: 64 * 1024,
// Limited due to the proof-of-work requirement
SMALL_GROUP_SIZE_LIMIT: 10,
NOTIFICATION_ENABLE_TIMEOUT_SECONDS: 10, // number of seconds to turn on notifications after reconnect/start of app
};
window.versionInfo = {

Loading…
Cancel
Save