Improve notification contents
Include sensible descriptions of non-content messages. For group messages, display the sender's name and avatar rather than the group's.
This commit is contained in:
parent
43ec4099c9
commit
718f1a5e3d
2 changed files with 20 additions and 7 deletions
|
@ -43,6 +43,16 @@
|
||||||
isIncoming: function() {
|
isIncoming: function() {
|
||||||
return this.get('type') === 'incoming';
|
return this.get('type') === 'incoming';
|
||||||
},
|
},
|
||||||
|
getDescription: function() {
|
||||||
|
if (this.isGroupUpdate()) {
|
||||||
|
return 'Updated the group';
|
||||||
|
}
|
||||||
|
if (this.isEndSession()) {
|
||||||
|
return 'Secure session ended';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.get('body');
|
||||||
|
},
|
||||||
getContact: function() {
|
getContact: function() {
|
||||||
if (this.collection) {
|
if (this.collection) {
|
||||||
return this.collection.conversation.contactCollection.get(this.get('source'));
|
return this.collection.conversation.contactCollection.get(this.get('source'));
|
||||||
|
|
|
@ -50,15 +50,18 @@
|
||||||
window.notifyConversation = function(message) {
|
window.notifyConversation = function(message) {
|
||||||
if (Whisper.Notifications.isEnabled()) {
|
if (Whisper.Notifications.isEnabled()) {
|
||||||
var conversation = getConversation({id: message.get('conversationId')});
|
var conversation = getConversation({id: message.get('conversationId')});
|
||||||
|
var sender = getConversation({id: message.get('source')});
|
||||||
conversation.fetch().then(function() {
|
conversation.fetch().then(function() {
|
||||||
var notification = new Notification(conversation.getTitle(), {
|
sender.fetch().then(function() {
|
||||||
body: message.get('body'),
|
var notification = new Notification(sender.getTitle(), {
|
||||||
icon: conversation.getAvatarUrl(),
|
body: message.getDescription(),
|
||||||
tag: conversation.id
|
icon: sender.getAvatarUrl(),
|
||||||
|
tag: conversation.id
|
||||||
|
});
|
||||||
|
notification.onclick = function() {
|
||||||
|
openConversation(conversation.id);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
notification.onclick = function() {
|
|
||||||
openConversation(conversation.id);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
conversation.fetchMessages();
|
conversation.fetchMessages();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue