From 8d4356a5b98bdb170036e84215401802b48d804d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 10 Jul 2019 08:57:00 +0100 Subject: [PATCH 1/2] Show anything other than ban/invite -> leave as a kick Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 5 ++--- src/components/views/elements/MemberEventListSummary.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index e3c65e7d08..56598c6e06 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -100,15 +100,14 @@ function textForMemberEvent(ev) { } } else if (prevContent.membership === "ban") { return _t('%(senderName)s unbanned %(targetName)s.', {senderName, targetName}); - } else if (prevContent.membership === "join") { - return _t('%(senderName)s kicked %(targetName)s.', {senderName, targetName}) + ' ' + reason; } else if (prevContent.membership === "invite") { return _t('%(senderName)s withdrew %(targetName)s\'s invitation.', { senderName, targetName, }) + ' ' + reason; } else { - return _t('%(targetName)s left the room.', {targetName}); + // sender is not target and made the target leave, if not from invite/ban then this is a kick + return _t('%(senderName)s kicked %(targetName)s.', {senderName, targetName}) + ' ' + reason; } } } diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index 9e48d780a9..6d8b490d98 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -345,8 +345,8 @@ module.exports = React.createClass({ switch (e.mxEvent.getPrevContent().membership) { case 'invite': return 'invite_withdrawal'; case 'ban': return 'unbanned'; - case 'join': return 'kicked'; - default: return 'left'; + // sender is not target and made the target leave, if not from invite/ban then this is a kick + default: return 'kicked'; } default: return null; } From 959f8fd8445e7c32f16383e4a53abc4138a01cdb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 10 Jul 2019 21:58:08 +0100 Subject: [PATCH 2/2] Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/elements/MemberEventListSummary-test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/components/views/elements/MemberEventListSummary-test.js b/test/components/views/elements/MemberEventListSummary-test.js index b593923ef9..f3749b850f 100644 --- a/test/components/views/elements/MemberEventListSummary-test.js +++ b/test/components/views/elements/MemberEventListSummary-test.js @@ -494,7 +494,14 @@ describe('MemberEventListSummary', function() { membership: "leave", senderId: "@some_other_user:some.domain", }, - // default = left + // default for sender=target (leave) + { + userId: "@user_1:some.domain", + prevMembership: "????", + membership: "leave", + senderId: "@user_1:some.domain", + }, + // default for sender<>target (kicked) { userId: "@user_1:some.domain", prevMembership: "????", @@ -520,7 +527,7 @@ describe('MemberEventListSummary', function() { expect(summaryText).toBe( "user_1 was invited, was banned, joined, rejected their invitation, left, " + - "had their invitation withdrawn, was unbanned, was kicked and left", + "had their invitation withdrawn, was unbanned, was kicked, left and was kicked", ); });