mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Show changes to related groups (flair) in the timeline
This commit is contained in:
parent
96eeab23af
commit
003d0eb0bf
3 changed files with 35 additions and 0 deletions
|
@ -166,6 +166,36 @@ function textForGuestAccessEvent(ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function textForRelatedGroupsEvent(ev) {
|
||||||
|
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
|
||||||
|
const groups = ev.getContent().groups || [];
|
||||||
|
const prevGroups = ev.getPrevContent().groups || [];
|
||||||
|
const added = groups.filter((g) => !prevGroups.includes(g));
|
||||||
|
const removed = prevGroups.filter((g) => !groups.includes(g));
|
||||||
|
|
||||||
|
if (added.length && !removed.length) {
|
||||||
|
return _t('%(senderDisplayName)s enabled flair for %(groups)s in this room.', {
|
||||||
|
senderDisplayName,
|
||||||
|
groups: added.join(', '),
|
||||||
|
});
|
||||||
|
} else if (!added.length && removed.length) {
|
||||||
|
return _t('%(senderDisplayName)s disabled flair for %(groups)s in this room.', {
|
||||||
|
senderDisplayName,
|
||||||
|
groups: removed.join(', '),
|
||||||
|
});
|
||||||
|
} else if (added.length && removed.length) {
|
||||||
|
return _t('%(senderDisplayName)s enabled flair for %(newGroups)s and disabled flair for ' +
|
||||||
|
'%(oldGroups)s in this room.', {
|
||||||
|
senderDisplayName,
|
||||||
|
newGroups: added.join(', '),
|
||||||
|
oldGroups: removed.join(', '),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Don't bother rendering this change (because there were no changes)
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function textForServerACLEvent(ev) {
|
function textForServerACLEvent(ev) {
|
||||||
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
|
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
|
||||||
const prevContent = ev.getPrevContent();
|
const prevContent = ev.getPrevContent();
|
||||||
|
@ -473,6 +503,7 @@ const stateHandlers = {
|
||||||
'm.room.tombstone': textForTombstoneEvent,
|
'm.room.tombstone': textForTombstoneEvent,
|
||||||
'm.room.join_rules': textForJoinRulesEvent,
|
'm.room.join_rules': textForJoinRulesEvent,
|
||||||
'm.room.guest_access': textForGuestAccessEvent,
|
'm.room.guest_access': textForGuestAccessEvent,
|
||||||
|
'm.room.related_groups': textForRelatedGroupsEvent,
|
||||||
|
|
||||||
'im.vector.modular.widgets': textForWidgetEvent,
|
'im.vector.modular.widgets': textForWidgetEvent,
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,6 +65,7 @@ const stateEventTileTypes = {
|
||||||
'm.room.tombstone': 'messages.TextualEvent',
|
'm.room.tombstone': 'messages.TextualEvent',
|
||||||
'm.room.join_rules': 'messages.TextualEvent',
|
'm.room.join_rules': 'messages.TextualEvent',
|
||||||
'm.room.guest_access': 'messages.TextualEvent',
|
'm.room.guest_access': 'messages.TextualEvent',
|
||||||
|
'm.room.related_groups': 'messages.TextualEvent',
|
||||||
};
|
};
|
||||||
|
|
||||||
function getHandlerTile(ev) {
|
function getHandlerTile(ev) {
|
||||||
|
|
|
@ -192,6 +192,9 @@
|
||||||
"%(senderDisplayName)s has allowed guests to join the room.": "%(senderDisplayName)s has allowed guests to join the room.",
|
"%(senderDisplayName)s has allowed guests to join the room.": "%(senderDisplayName)s has allowed guests to join the room.",
|
||||||
"%(senderDisplayName)s has prevented guests from joining the room.": "%(senderDisplayName)s has prevented guests from joining the room.",
|
"%(senderDisplayName)s has prevented guests from joining the room.": "%(senderDisplayName)s has prevented guests from joining the room.",
|
||||||
"%(senderDisplayName)s changed guest access to %(rule)s": "%(senderDisplayName)s changed guest access to %(rule)s",
|
"%(senderDisplayName)s changed guest access to %(rule)s": "%(senderDisplayName)s changed guest access to %(rule)s",
|
||||||
|
"%(senderDisplayName)s enabled flair for %(groups)s in this room.": "%(senderDisplayName)s enabled flair for %(groups)s in this room.",
|
||||||
|
"%(senderDisplayName)s disabled flair for %(groups)s in this room.": "%(senderDisplayName)s disabled flair for %(groups)s in this room.",
|
||||||
|
"%(senderDisplayName)s enabled flair for %(newGroups)s and disabled flair for %(oldGroups)s in this room.": "%(senderDisplayName)s enabled flair for %(newGroups)s and disabled flair for %(oldGroups)s in this room.",
|
||||||
"%(senderDisplayName)s sent an image.": "%(senderDisplayName)s sent an image.",
|
"%(senderDisplayName)s sent an image.": "%(senderDisplayName)s sent an image.",
|
||||||
"%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|other": "%(senderName)s added %(addedAddresses)s as addresses for this room.",
|
"%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|other": "%(senderName)s added %(addedAddresses)s as addresses for this room.",
|
||||||
"%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|one": "%(senderName)s added %(addedAddresses)s as an address for this room.",
|
"%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|one": "%(senderName)s added %(addedAddresses)s as an address for this room.",
|
||||||
|
|
Loading…
Reference in a new issue