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; var title;
if (!ev.sender || room.name == ev.sender.name) { if (!ev.sender || room.name == ev.sender.name) {
title = room.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) { } else if (ev.sender) {
title = ev.sender.name + " (" + room.name + ")"; 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( 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 = { var handlers = {
'm.room.message': textForMessageEvent,
'm.room.member': textForMemberEvent 'm.room.member': textForMemberEvent
}; };