debounce notifications update to 2sec

pull/924/head
Audric Ackermann 5 years ago
parent f5b3eb394c
commit ff8c2fc050
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -34,8 +34,6 @@
Whisper.Notifications = new (Backbone.Collection.extend({ Whisper.Notifications = new (Backbone.Collection.extend({
initialize() { initialize() {
this.isEnabled = false; this.isEnabled = false;
this.on('add', this.update);
this.on('remove', this.onRemove);
this.lastNotification = null; this.lastNotification = null;
@ -45,7 +43,11 @@
// and batches up the quick successive update() calls we get from an incoming // 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. // read sync, which might have a number of messages referenced inside of it.
this.fastUpdate = this.update; 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() { update() {
if (this.lastNotification) { if (this.lastNotification) {

Loading…
Cancel
Save