mirror of https://github.com/vector-im/riot-web
Make notifications sensible again and have information once and only once.
parent
1b03aa8119
commit
37108ac56c
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue