Remove usage of extension.trigger
This trigger function uses chrome's runtime message passing api, which traverses between different windows in our runtime, but we only trigger the updateInbox event from the backgroud page, so we don't need to use that api, which requires some extra cpu/memory overhead. // FREEBIE
This commit is contained in:
parent
2ad422afc8
commit
9dfff879b6
4 changed files with 8 additions and 9 deletions
|
@ -137,13 +137,13 @@
|
|||
var message = initIncomingMessage(envelope.source, envelope.timestamp.toNumber());
|
||||
if (e.name === 'IncomingIdentityKeyError') {
|
||||
message.save({ errors : [e] }).then(function() {
|
||||
extension.trigger('updateInbox');
|
||||
updateInbox();
|
||||
notifyConversation(message);
|
||||
});
|
||||
return;
|
||||
} else if (e.message !== 'Bad MAC') {
|
||||
message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() {
|
||||
extension.trigger('updateInbox');
|
||||
updateInbox();
|
||||
notifyConversation(message);
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
timestamp : now,
|
||||
lastMessage : body
|
||||
}).then(function() {
|
||||
extension.trigger('updateInbox'); // inbox fetch
|
||||
updateInbox();
|
||||
});
|
||||
|
||||
var sendFunc;
|
||||
|
@ -108,7 +108,7 @@
|
|||
});
|
||||
if (keyErrors.length) {
|
||||
message.save({ errors : keyErrors }).then(function() {
|
||||
extension.trigger('updateInbox'); // notify frontend listeners
|
||||
updateInbox();
|
||||
});
|
||||
} else {
|
||||
if (!(errors instanceof Array)) {
|
||||
|
@ -188,7 +188,7 @@
|
|||
_.each(models, function(message) { message.destroy(); });
|
||||
this.archive();
|
||||
return this.save().then(function() {
|
||||
extension.trigger('updateInbox');
|
||||
updateInbox();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
|
||||
conversation.save().then(function() {
|
||||
message.save().then(function() {
|
||||
extension.trigger('updateInbox'); // inbox fetch
|
||||
updateInbox();
|
||||
if (message.isIncoming()) {
|
||||
notifyConversation(message);
|
||||
} else {
|
||||
|
|
|
@ -41,15 +41,14 @@
|
|||
}
|
||||
});
|
||||
|
||||
function updateInbox() {
|
||||
window.updateInbox = function() {
|
||||
conversations.fetchActive().then(function() {
|
||||
inbox.reset(conversations.filter(function(model) {
|
||||
return model.get('active_at');
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
extension.on('updateInbox', updateInbox);
|
||||
updateInbox();
|
||||
setUnreadCount(storage.get("unreadCount", 0));
|
||||
|
||||
|
|
Loading…
Reference in a new issue