render m.room.aliases events

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-09-14 13:43:46 +01:00
parent 738c81b506
commit 8ab96ae2ff
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E
2 changed files with 33 additions and 0 deletions

View file

@ -134,6 +134,37 @@ function textForMessageEvent(ev) {
return message;
}
function textForRoomAliasesEvent(ev) {
const senderName = event.sender ? event.sender.name : event.getSender();
const oldAliases = ev.getPrevContent().aliases || [];
const newAliases = ev.getContent().aliases || [];
const addedAliases = newAliases.filter((x) => !oldAliases.includes(x));
const removedAliases = oldAliases.filter((x) => !newAliases.includes(x));
if (!addedAliases.length && !removedAliases.length) {
return '';
}
if (addedAliases.length && !removedAliases.length) {
return _t('%(senderName)s added %(addedAddresses)s as addresses for this room.', {
senderName: senderName,
addedAddresses: addedAliases.join(', '),
});
} else if (!addedAliases.length && removedAliases.length) {
return _t('%(senderName)s removed %(addresses)s as addresses for this room.', {
senderName: senderName,
removedAddresses: removedAliases.join(', '),
});
} else {
return _t('%(senderName)s added %(addedAddresses)s and removed %(removedAddresses)s as addresses for this room.', {
senderName: senderName,
addedAddresses: addedAliases.join(', '),
removedAddresses: removedAliases.join(', '),
});
}
}
function textForCallAnswerEvent(event) {
var senderName = event.sender ? event.sender.name : _t('Someone');
var supported = MatrixClientPeg.get().supportsVoip() ? "" : _t('(not supported by this browser)');
@ -280,6 +311,7 @@ function textForWidgetEvent(event) {
var handlers = {
'm.room.message': textForMessageEvent,
'm.room.aliases': textForRoomAliasesEvent,
'm.room.name': textForRoomNameEvent,
'm.room.topic': textForTopicEvent,
'm.room.member': textForMemberEvent,

View file

@ -33,6 +33,7 @@ var ObjectUtils = require('../../../ObjectUtils');
var eventTileTypes = {
'm.room.message': 'messages.MessageEvent',
'm.room.aliases': 'messages.TextualEvent',
'm.room.member' : 'messages.TextualEvent',
'm.call.invite' : 'messages.TextualEvent',
'm.call.answer' : 'messages.TextualEvent',