summarise profile changes in MELS

fixes https://github.com/vector-im/riot-web/issues/3463
This commit is contained in:
Matthew Hodgson 2017-04-23 04:05:50 +01:00
parent a2be764681
commit 24f2aed45f
2 changed files with 21 additions and 4 deletions

View file

@ -279,9 +279,7 @@ module.exports = React.createClass({
this.currentGhostEventId = null; this.currentGhostEventId = null;
} }
var isMembershipChange = (e) => var isMembershipChange = (e) => e.getType() === 'm.room.member';
e.getType() === 'm.room.member'
&& (!e.getPrevContent() || e.getContent().membership !== e.getPrevContent().membership);
for (i = 0; i < this.props.events.length; i++) { for (i = 0; i < this.props.events.length; i++) {
var mxEv = this.props.events[i]; var mxEv = this.props.events[i];

View file

@ -221,6 +221,8 @@ module.exports = React.createClass({
"banned": beConjugated + " banned", "banned": beConjugated + " banned",
"unbanned": beConjugated + " unbanned", "unbanned": beConjugated + " unbanned",
"kicked": beConjugated + " kicked", "kicked": beConjugated + " kicked",
"changed_name": "changed name",
"changed_avatar": "changed avatar",
}; };
if (Object.keys(map).includes(t)) { if (Object.keys(map).includes(t)) {
@ -289,7 +291,24 @@ module.exports = React.createClass({
switch (e.mxEvent.getContent().membership) { switch (e.mxEvent.getContent().membership) {
case 'invite': return 'invited'; case 'invite': return 'invited';
case 'ban': return 'banned'; case 'ban': return 'banned';
case 'join': return 'joined'; case 'join':
if (e.mxEvent.getPrevContent().membership === 'join') {
if (e.mxEvent.getContent().displayname !==
e.mxEvent.getPrevContent().displayname)
{
return 'changed_name';
}
else if (e.mxEvent.getContent().avatar_url !==
e.mxEvent.getPrevContent().avatar_url)
{
return 'changed_avatar';
}
console.info("MELS ignoring duplicate membership join event");
return null;
}
else {
return 'joined';
}
case 'leave': case 'leave':
if (e.mxEvent.getSender() === e.mxEvent.getStateKey()) { if (e.mxEvent.getSender() === e.mxEvent.getStateKey()) {
switch (e.mxEvent.getPrevContent().membership) { switch (e.mxEvent.getPrevContent().membership) {