Merge pull request #1769 from matrix-org/t3chguy/fix_hide_joins_parts

fix shouldHideEvent saying an event is a leave/join when a profile ch…
This commit is contained in:
Luke Barnard 2018-02-28 16:58:26 +00:00 committed by GitHub
commit fa9ff4ae6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 isMembershipChanged = content.membership !== prevContent.membership;
diff.isJoin = isMembershipChanged && content.membership === 'join';
diff.isPart = isMembershipChanged && content.membership === 'leave' && ev.getStateKey() === ev.getSender();
const isJoinToJoin = content.membership === prevContent.membership && content.membership === 'join';
const isJoinToJoin = !isMembershipChanged && content.membership === 'join';
diff.isDisplaynameChange = isJoinToJoin && content.displayname !== prevContent.displayname;
diff.isAvatarChange = isJoinToJoin && content.avatar_url !== prevContent.avatar_url;
return diff;