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:
parent
e9d7864f75
commit
08878b3dc8
4 changed files with 7 additions and 5 deletions
|
@ -84,12 +84,12 @@
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
if (e.name === 'IncomingIdentityKeyError') {
|
if (e.name === 'IncomingIdentityKeyError') {
|
||||||
message.save({ errors : [e] }).then(function() {
|
message.save({ errors : [e] }).then(function() {
|
||||||
extension.trigger('message', message);
|
extension.trigger('updateInbox');
|
||||||
notifyConversation(message);
|
notifyConversation(message);
|
||||||
});
|
});
|
||||||
} else if (e.message === 'Bad MAC') {
|
} else if (e.message === 'Bad MAC') {
|
||||||
message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() {
|
message.save({ errors : [ _.pick(e, ['name', 'message'])]}).then(function() {
|
||||||
extension.trigger('message', message);
|
extension.trigger('updateInbox');
|
||||||
notifyConversation(message);
|
notifyConversation(message);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.on('message', fetch);
|
extension.on('updateInbox', fetch);
|
||||||
fetch();
|
fetch();
|
||||||
setUnreadCount(storage.get("unreadCount", 0));
|
setUnreadCount(storage.get("unreadCount", 0));
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,8 @@
|
||||||
active_at : now,
|
active_at : now,
|
||||||
timestamp : now,
|
timestamp : now,
|
||||||
lastMessage : body
|
lastMessage : body
|
||||||
|
}).then(function() {
|
||||||
|
extension.trigger('updateInbox'); // inbox fetch
|
||||||
});
|
});
|
||||||
|
|
||||||
var sendFunc;
|
var sendFunc;
|
||||||
|
@ -102,7 +104,7 @@
|
||||||
});
|
});
|
||||||
if (keyErrors.length) {
|
if (keyErrors.length) {
|
||||||
message.save({ errors : keyErrors }).then(function() {
|
message.save({ errors : keyErrors }).then(function() {
|
||||||
extension.trigger('message', message); // notify frontend listeners
|
extension.trigger('updateInbox'); // notify frontend listeners
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!(errors instanceof Array)) {
|
if (!(errors instanceof Array)) {
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
|
|
||||||
conversation.save().then(function() {
|
conversation.save().then(function() {
|
||||||
message.save().then(function() {
|
message.save().then(function() {
|
||||||
extension.trigger('message', message); // inbox fetch
|
extension.trigger('updateInbox'); // inbox fetch
|
||||||
if (message.isIncoming()) {
|
if (message.isIncoming()) {
|
||||||
notifyConversation(message);
|
notifyConversation(message);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue