mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Merge pull request #42 from bwindels/bwindels/fixnamechangeshownasjoin
look at prev_content when handling member events
This commit is contained in:
commit
2f7c825d2b
@ -7,20 +7,37 @@ export default class RoomNameTile extends SimpleTile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get announcement() {
|
get announcement() {
|
||||||
const {sender, content, stateKey} = this._entry;
|
const {sender, content, prevContent, stateKey} = this._entry;
|
||||||
switch (content.membership) {
|
const membership = content && content.membership;
|
||||||
case "invite": return `${stateKey} was invited to the room by ${sender}`;
|
const prevMembership = prevContent && prevContent.membership;
|
||||||
case "join": return `${stateKey} joined the room`;
|
|
||||||
case "leave": {
|
if (prevMembership === "join" && membership === "join") {
|
||||||
if (stateKey === sender) {
|
if (content.avatar_url !== prevContent.avatar_url) {
|
||||||
return `${stateKey} left the room`;
|
return `${stateKey} changed their avatar`;
|
||||||
} else {
|
} else if (content.displayname !== prevContent.displayname) {
|
||||||
const reason = content.reason;
|
return `${stateKey} changed their name to ${content.displayname}`;
|
||||||
return `${stateKey} was kicked from the room by ${sender}${reason ? `: ${reason}` : ""}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "ban": return `${stateKey} was banned from the room by ${sender}`;
|
} else if (membership === "join") {
|
||||||
default: return `${sender} membership changed to ${content.membership}`;
|
return `${stateKey} joined the room`;
|
||||||
|
} else if (membership === "invite") {
|
||||||
|
return `${stateKey} was invited to the room by ${sender}`;
|
||||||
|
} else if (prevMembership === "invite") {
|
||||||
|
if (membership === "join") {
|
||||||
|
return `${stateKey} accepted the invitation to join the room`;
|
||||||
|
} else if (membership === "leave") {
|
||||||
|
return `${stateKey} declined the invitation to join the room`;
|
||||||
|
}
|
||||||
|
} else if (membership === "leave") {
|
||||||
|
if (stateKey === sender) {
|
||||||
|
return `${stateKey} left the room`;
|
||||||
|
} else {
|
||||||
|
const reason = content.reason;
|
||||||
|
return `${stateKey} was kicked from the room by ${sender}${reason ? `: ${reason}` : ""}`;
|
||||||
|
}
|
||||||
|
} else if (membership === "ban") {
|
||||||
|
return `${stateKey} was banned from the room by ${sender}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return `${sender} membership changed to ${content.membership}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,11 @@ export default class EventEntry extends BaseEntry {
|
|||||||
return this._eventEntry.event.content;
|
return this._eventEntry.event.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get prevContent() {
|
||||||
|
const unsigned = this._eventEntry.event.unsigned;
|
||||||
|
return unsigned && unsigned.prev_content;
|
||||||
|
}
|
||||||
|
|
||||||
get eventType() {
|
get eventType() {
|
||||||
return this._eventEntry.event.type;
|
return this._eventEntry.event.type;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user