From 773fef7f1d0261d472b21bba4fe60b8d1d736db6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 22 Feb 2018 16:14:56 +0000 Subject: [PATCH 1/2] fix shouldHideEvent saying an event is a leave/join when a profile change Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/shouldHideEvent.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shouldHideEvent.js b/src/shouldHideEvent.js index 1ecd1ac051..ae7be56c2e 100644 --- a/src/shouldHideEvent.js +++ b/src/shouldHideEvent.js @@ -27,10 +27,11 @@ function memberEventDiff(ev) { const content = ev.getContent(); const prevContent = ev.getPrevContent(); - diff.isJoin = content.membership === 'join' && prevContent.membership !== 'ban'; - diff.isPart = content.membership === 'leave' && ev.getStateKey() === ev.getSender(); - const isJoinToJoin = content.membership === prevContent.membership && content.membership === 'join'; + + diff.isJoin = !isJoinToJoin && content.membership === 'join' && prevContent.membership !== 'ban'; + diff.isPart = !isJoinToJoin && content.membership === 'leave' && ev.getStateKey() === ev.getSender(); + diff.isDisplaynameChange = isJoinToJoin && content.displayname !== prevContent.displayname; diff.isAvatarChange = isJoinToJoin && content.avatar_url !== prevContent.avatar_url; return diff; From bd4b40309dbb07814b1a505aecb1699559188fca Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 28 Feb 2018 00:49:14 +0000 Subject: [PATCH 2/2] fix based on PR review Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/shouldHideEvent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shouldHideEvent.js b/src/shouldHideEvent.js index ae7be56c2e..3aad05a976 100644 --- a/src/shouldHideEvent.js +++ b/src/shouldHideEvent.js @@ -27,11 +27,11 @@ function memberEventDiff(ev) { const content = ev.getContent(); const prevContent = ev.getPrevContent(); - const isJoinToJoin = content.membership === prevContent.membership && content.membership === 'join'; - - diff.isJoin = !isJoinToJoin && content.membership === 'join' && prevContent.membership !== 'ban'; - diff.isPart = !isJoinToJoin && content.membership === 'leave' && ev.getStateKey() === ev.getSender(); + const isMembershipChanged = content.membership !== prevContent.membership; + diff.isJoin = isMembershipChanged && content.membership === 'join'; + diff.isPart = isMembershipChanged && content.membership === 'leave' && ev.getStateKey() === ev.getSender(); + const isJoinToJoin = !isMembershipChanged && content.membership === 'join'; diff.isDisplaynameChange = isJoinToJoin && content.displayname !== prevContent.displayname; diff.isAvatarChange = isJoinToJoin && content.avatar_url !== prevContent.avatar_url; return diff;