Conversation.notify(): introduce a promise to track completion

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-08-03 18:12:08 -07:00
parent d3fb0e5b46
commit 32e12f7d3c

View file

@ -815,16 +815,19 @@
notify: function(message) { notify: function(message) {
if (!message.isIncoming()) { if (!message.isIncoming()) {
return; return Promise.resolve();
} }
if (window.isOpen() && window.isFocused()) { if (window.isOpen() && window.isFocused()) {
return; return Promise.resolve();
} }
window.drawAttention(); window.drawAttention();
var sender = ConversationController.create({ var sender = ConversationController.create({
id: message.get('source'), type: 'private' id: message.get('source'), type: 'private'
}); });
var conversationId = this.id; var conversationId = this.id;
return new Promise(function(resolve, reject) {
sender.fetch().then(function() { sender.fetch().then(function() {
sender.getNotificationIcon().then(function(iconUrl) { sender.getNotificationIcon().then(function(iconUrl) {
console.log('adding notification'); console.log('adding notification');
@ -836,7 +839,10 @@
conversationId : conversationId, conversationId : conversationId,
messageId : message.id messageId : message.id
}); });
});
return resolve();
}, reject);
}, reject);
}); });
}, },
hashCode: function() { hashCode: function() {