Throttle expiring messages data query and deletion

I believe this to be the reason behind some of the high resource usage
on startup. If a lot of read receipts come in for disappearing messages,
this method can be called many, many times very quickly.

FREEBIE
pull/749/head
Scott Nonnenberg 8 years ago
parent b2690afa32
commit 96b00b3e2d

@ -17,7 +17,7 @@
// the expiration before the message is removed from the database.
message.destroy();
});
expired.on('reset', checkExpiringMessages);
expired.on('reset', throttledCheckExpiringMessages);
expired.fetchExpired();
}
@ -38,13 +38,14 @@
});
expiring.fetchNextExpiring();
}
var throttledCheckExpiringMessages = _.throttle(checkExpiringMessages, 1000);
Whisper.ExpiringMessagesListener = {
init: function(events) {
checkExpiringMessages();
events.on('timetravel', checkExpiringMessages);
events.on('timetravel', throttledCheckExpiringMessages);
},
update: checkExpiringMessages
update: throttledCheckExpiringMessages
};
var TimerOption = Backbone.Model.extend({

Loading…
Cancel
Save