Update inbox after sending a message

Also change the event name to reflect how its being used, and stop
passing the message object around since it is not being used.

// FREEBIE
This commit is contained in:
lilia 2015-05-20 13:04:16 -07:00
parent e9d7864f75
commit 08878b3dc8
4 changed files with 7 additions and 5 deletions

View file

@ -84,12 +84,12 @@
}).catch(function(e) {
if (e.name === 'IncomingIdentityKeyError') {
message.save({ errors : [e] }).then(function() {
extension.trigger('message', message);
extension.trigger('updateInbox');
notifyConversation(message);
});
} else if (e.message === 'Bad MAC') {
message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() {
extension.trigger('message', message);
extension.trigger('updateInbox');
notifyConversation(message);
});
} else {

View file

@ -50,7 +50,7 @@
});
}
extension.on('message', fetch);
extension.on('updateInbox', fetch);
fetch();
setUnreadCount(storage.get("unreadCount", 0));

View file

@ -84,6 +84,8 @@
active_at : now,
timestamp : now,
lastMessage : body
}).then(function() {
extension.trigger('updateInbox'); // inbox fetch
});
var sendFunc;
@ -102,7 +104,7 @@
});
if (keyErrors.length) {
message.save({ errors : keyErrors }).then(function() {
extension.trigger('message', message); // notify frontend listeners
extension.trigger('updateInbox'); // notify frontend listeners
});
} else {
if (!(errors instanceof Array)) {

View file

@ -228,7 +228,7 @@
conversation.save().then(function() {
message.save().then(function() {
extension.trigger('message', message); // inbox fetch
extension.trigger('updateInbox'); // inbox fetch
if (message.isIncoming()) {
notifyConversation(message);
} else {