Update membership reason handling, including leave reason displaying
Incorporates ideas from https://github.com/matrix-org/matrix-react-sdk/pull/6198
This commit is contained in:
parent
ef2dcaea3d
commit
e696a1d5dc
2 changed files with 35 additions and 18 deletions
|
@ -31,8 +31,8 @@ function textForMemberEvent(ev): () => string | null {
|
|||
const targetName = ev.target ? ev.target.name : ev.getStateKey();
|
||||
const prevContent = ev.getPrevContent();
|
||||
const content = ev.getContent();
|
||||
const reason = content.reason;
|
||||
|
||||
const getReason = () => content.reason ? (_t('Reason') + ': ' + content.reason) : '';
|
||||
switch (content.membership) {
|
||||
case 'invite': {
|
||||
const threePidContent = content.third_party_invite;
|
||||
|
@ -50,7 +50,9 @@ function textForMemberEvent(ev): () => string | null {
|
|||
}
|
||||
}
|
||||
case 'ban':
|
||||
return () => _t('%(senderName)s banned %(targetName)s.', {senderName, targetName}) + ' ' + getReason();
|
||||
return () => reason
|
||||
? _t('%(senderName)s banned %(targetName)s. Reason: %(reason)s', { senderName, targetName, reason })
|
||||
: _t('%(senderName)s banned %(targetName)s.', { senderName, targetName });
|
||||
case 'join':
|
||||
if (prevContent && prevContent.membership === 'join') {
|
||||
if (prevContent.displayname && content.displayname && prevContent.displayname !== content.displayname) {
|
||||
|
@ -90,17 +92,28 @@ function textForMemberEvent(ev): () => string | null {
|
|||
if (prevContent.membership === "invite") {
|
||||
return () => _t('%(targetName)s rejected the invitation.', { targetName });
|
||||
} else {
|
||||
return () => _t('%(targetName)s left the room.', {targetName});
|
||||
return () => reason
|
||||
? _t('%(targetName)s left the room. Reason: %(reason)s', { targetName, reason })
|
||||
: _t('%(targetName)s left the room.', { targetName });
|
||||
}
|
||||
} else if (prevContent.membership === "ban") {
|
||||
return () => _t('%(senderName)s unbanned %(targetName)s.', { senderName, targetName });
|
||||
} else if (prevContent.membership === "invite") {
|
||||
return () => _t('%(senderName)s withdrew %(targetName)s\'s invitation.', {
|
||||
return () => reason
|
||||
? _t('%(senderName)s withdrew %(targetName)s\'s invitation. Reason: %(reason)s', {
|
||||
senderName,
|
||||
targetName,
|
||||
}) + ' ' + getReason();
|
||||
reason,
|
||||
})
|
||||
: _t('%(senderName)s withdrew %(targetName)s\'s invitation.', { senderName, targetName })
|
||||
} else if (prevContent.membership === "join") {
|
||||
return () => _t('%(senderName)s kicked %(targetName)s.', {senderName, targetName}) + ' ' + getReason();
|
||||
return () => reason
|
||||
? _t('%(senderName)s kicked %(targetName)s. Reason: %(reason)s', {
|
||||
senderName,
|
||||
targetName,
|
||||
reason,
|
||||
})
|
||||
: _t('%(senderName)s kicked %(targetName)s.', { senderName, targetName });
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -489,10 +489,10 @@
|
|||
"Converts the room to a DM": "Converts the room to a DM",
|
||||
"Converts the DM to a room": "Converts the DM to a room",
|
||||
"Displays action": "Displays action",
|
||||
"Reason": "Reason",
|
||||
"%(targetName)s accepted the invitation for %(displayName)s.": "%(targetName)s accepted the invitation for %(displayName)s.",
|
||||
"%(targetName)s accepted an invitation.": "%(targetName)s accepted an invitation.",
|
||||
"%(senderName)s invited %(targetName)s.": "%(senderName)s invited %(targetName)s.",
|
||||
"%(senderName)s banned %(targetName)s. Reason: %(reason)s": "%(senderName)s banned %(targetName)s. Reason: %(reason)s",
|
||||
"%(senderName)s banned %(targetName)s.": "%(senderName)s banned %(targetName)s.",
|
||||
"%(oldDisplayName)s changed their display name to %(displayName)s.": "%(oldDisplayName)s changed their display name to %(displayName)s.",
|
||||
"%(senderName)s set their display name to %(displayName)s.": "%(senderName)s set their display name to %(displayName)s.",
|
||||
|
@ -503,9 +503,12 @@
|
|||
"%(senderName)s made no change.": "%(senderName)s made no change.",
|
||||
"%(targetName)s joined the room.": "%(targetName)s joined the room.",
|
||||
"%(targetName)s rejected the invitation.": "%(targetName)s rejected the invitation.",
|
||||
"%(targetName)s left the room. Reason: %(reason)s": "%(targetName)s left the room. Reason: %(reason)s",
|
||||
"%(targetName)s left the room.": "%(targetName)s left the room.",
|
||||
"%(senderName)s unbanned %(targetName)s.": "%(senderName)s unbanned %(targetName)s.",
|
||||
"%(senderName)s withdrew %(targetName)s's invitation. Reason: %(reason)s": "%(senderName)s withdrew %(targetName)s's invitation. Reason: %(reason)s",
|
||||
"%(senderName)s withdrew %(targetName)s's invitation.": "%(senderName)s withdrew %(targetName)s's invitation.",
|
||||
"%(senderName)s kicked %(targetName)s. Reason: %(reason)s": "%(senderName)s kicked %(targetName)s. Reason: %(reason)s",
|
||||
"%(senderName)s kicked %(targetName)s.": "%(senderName)s kicked %(targetName)s.",
|
||||
"%(senderDisplayName)s changed the topic to \"%(topic)s\".": "%(senderDisplayName)s changed the topic to \"%(topic)s\".",
|
||||
"%(senderDisplayName)s removed the room name.": "%(senderDisplayName)s removed the room name.",
|
||||
|
@ -1410,6 +1413,7 @@
|
|||
"Failed to unban": "Failed to unban",
|
||||
"Unban": "Unban",
|
||||
"Banned by %(displayName)s": "Banned by %(displayName)s",
|
||||
"Reason": "Reason",
|
||||
"Error changing power level requirement": "Error changing power level requirement",
|
||||
"An error occurred changing the room's power level requirements. Ensure you have sufficient permissions and try again.": "An error occurred changing the room's power level requirements. Ensure you have sufficient permissions and try again.",
|
||||
"Error changing power level": "Error changing power level",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue