fix based on PR review

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2018-02-28 00:49:14 +00:00
parent 4c4c9506ca
commit bd4b40309d
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
1 changed files with 4 additions and 4 deletions

View File

@ -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;