Conversation.notify(): introduce a promise to track completion
FREEBIE
This commit is contained in:
parent
d3fb0e5b46
commit
32e12f7d3c
1 changed files with 20 additions and 14 deletions
|
@ -815,28 +815,34 @@
|
||||||
|
|
||||||
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;
|
||||||
sender.fetch().then(function() {
|
|
||||||
sender.getNotificationIcon().then(function(iconUrl) {
|
return new Promise(function(resolve, reject) {
|
||||||
console.log('adding notification');
|
sender.fetch().then(function() {
|
||||||
Whisper.Notifications.add({
|
sender.getNotificationIcon().then(function(iconUrl) {
|
||||||
title : sender.getTitle(),
|
console.log('adding notification');
|
||||||
message : message.getNotificationText(),
|
Whisper.Notifications.add({
|
||||||
iconUrl : iconUrl,
|
title : sender.getTitle(),
|
||||||
imageUrl : message.getImageUrl(),
|
message : message.getNotificationText(),
|
||||||
conversationId : conversationId,
|
iconUrl : iconUrl,
|
||||||
messageId : message.id
|
imageUrl : message.getImageUrl(),
|
||||||
});
|
conversationId : conversationId,
|
||||||
});
|
messageId : message.id
|
||||||
|
});
|
||||||
|
|
||||||
|
return resolve();
|
||||||
|
}, reject);
|
||||||
|
}, reject);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
hashCode: function() {
|
hashCode: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue