Make notifications sensible again and have information once and only once.

This commit is contained in:
David Baker 2015-07-17 11:56:55 +01:00
parent 1b03aa8119
commit 37108ac56c
2 changed files with 23 additions and 0 deletions

View file

@ -43,8 +43,18 @@ var NotifierView = {
var title;
if (!ev.sender || room.name == ev.sender.name) {
title = room.name;
// notificationMessageForEvent includes sender,
// but we already have the sender here
if (ev.getContent().body) msg = ev.getContent().body;
} else if (ev.getType() == 'm.room.member') {
// context is all in the message here, we don't need
// to display sender info
title = room.name;
} else if (ev.sender) {
title = ev.sender.name + " (" + room.name + ")";
// notificationMessageForEvent includes sender,
// but we've just out sender in the title
if (ev.getContent().body) msg = ev.getContent().body;
}
var notification = new global.Notification(

View file

@ -25,7 +25,20 @@ function textForMemberEvent(ev) {
}
};
function textForMessageEvent(ev) {
var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
var message = senderDisplayName + ': ' + ev.getContent().body;
if (ev.getContent().msgtype === "m.emote") {
message = "* " + senderDisplayName + " " + message;
} else if (ev.getContent().msgtype === "m.image") {
message = senderDisplayName + " sent an image.";
}
return message;
};
var handlers = {
'm.room.message': textForMessageEvent,
'm.room.member': textForMemberEvent
};