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;