Trigger desktop notifications

Notifications show the conversation name, avatar, and new message text.
Clicking the notification opens the conversation.
This commit is contained in:
lilia 2015-03-17 15:06:21 -07:00
parent f8e69fa8e7
commit fa3699cdd3
7 changed files with 115 additions and 4 deletions

View file

@ -36,6 +36,8 @@
this.messageCollection = new Whisper.MessageCollection([], {
conversation: this
});
this.on('change:avatar', this.updateAvatarUrl);
},
validate: function(attributes, options) {
@ -190,6 +192,28 @@
},
isPrivate: function() {
return this.get('type') === 'private';
},
updateAvatarUrl: function() {
if (this.avatarUrl) {
URL.revokeObjectURL(this.avatarUrl);
this.avatarUrl = null;
}
var avatar = this.get('avatar');
if (avatar) {
this.avatarUrl = URL.createObjectURL(
new Blob([avatar.data], {type: avatar.contentType})
);
} else {
this.avatarUrl = null;
}
},
getAvatarUrl: function() {
if (this.avatarUrl === undefined) {
this.updateAvatarUrl();
}
return this.avatarUrl || '/images/default.png';
}
});