render display name in timeline
This commit is contained in:
parent
41c00ce44a
commit
d31a1b5fff
3 changed files with 21 additions and 12 deletions
|
@ -31,7 +31,7 @@ export class MessageTile extends SimpleTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
get sender() {
|
get sender() {
|
||||||
return this._entry.sender;
|
return this._entry.displayName || this._entry.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
get senderColorNumber() {
|
get senderColorNumber() {
|
||||||
|
|
|
@ -23,35 +23,36 @@ export class RoomMemberTile extends SimpleTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
get announcement() {
|
get announcement() {
|
||||||
const {sender, content, prevContent, stateKey} = this._entry;
|
const {sender, content, prevContent} = this._entry;
|
||||||
|
const name = this._entry.displayName || sender;
|
||||||
const membership = content && content.membership;
|
const membership = content && content.membership;
|
||||||
const prevMembership = prevContent && prevContent.membership;
|
const prevMembership = prevContent && prevContent.membership;
|
||||||
|
|
||||||
if (prevMembership === "join" && membership === "join") {
|
if (prevMembership === "join" && membership === "join") {
|
||||||
if (content.avatar_url !== prevContent.avatar_url) {
|
if (content.avatar_url !== prevContent.avatar_url) {
|
||||||
return `${stateKey} changed their avatar`;
|
return `${name} changed their avatar`;
|
||||||
} else if (content.displayname !== prevContent.displayname) {
|
} else if (content.displayname !== prevContent.displayname) {
|
||||||
return `${stateKey} changed their name to ${content.displayname}`;
|
return `${name} changed their name to ${content.displayname}`;
|
||||||
}
|
}
|
||||||
} else if (membership === "join") {
|
} else if (membership === "join") {
|
||||||
return `${stateKey} joined the room`;
|
return `${name} joined the room`;
|
||||||
} else if (membership === "invite") {
|
} else if (membership === "invite") {
|
||||||
return `${stateKey} was invited to the room by ${sender}`;
|
return `${name} was invited to the room by ${sender}`;
|
||||||
} else if (prevMembership === "invite") {
|
} else if (prevMembership === "invite") {
|
||||||
if (membership === "join") {
|
if (membership === "join") {
|
||||||
return `${stateKey} accepted the invitation to join the room`;
|
return `${name} accepted the invitation to join the room`;
|
||||||
} else if (membership === "leave") {
|
} else if (membership === "leave") {
|
||||||
return `${stateKey} declined the invitation to join the room`;
|
return `${name} declined the invitation to join the room`;
|
||||||
}
|
}
|
||||||
} else if (membership === "leave") {
|
} else if (membership === "leave") {
|
||||||
if (stateKey === sender) {
|
if (name === sender) {
|
||||||
return `${stateKey} left the room`;
|
return `${name} left the room`;
|
||||||
} else {
|
} else {
|
||||||
const reason = content.reason;
|
const reason = content.reason;
|
||||||
return `${stateKey} was kicked from the room by ${sender}${reason ? `: ${reason}` : ""}`;
|
return `${name} was kicked from the room by ${sender}${reason ? `: ${reason}` : ""}`;
|
||||||
}
|
}
|
||||||
} else if (membership === "ban") {
|
} else if (membership === "ban") {
|
||||||
return `${stateKey} was banned from the room by ${sender}`;
|
return `${name} was banned from the room by ${sender}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${sender} membership changed to ${content.membership}`;
|
return `${sender} membership changed to ${content.membership}`;
|
||||||
|
|
|
@ -50,6 +50,14 @@ export class EventEntry extends BaseEntry {
|
||||||
return this._eventEntry.event.sender;
|
return this._eventEntry.event.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get displayName() {
|
||||||
|
return this._eventEntry.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
get avatarUrl() {
|
||||||
|
return this._eventEntry.avatarUrl;
|
||||||
|
}
|
||||||
|
|
||||||
get timestamp() {
|
get timestamp() {
|
||||||
return this._eventEntry.event.origin_server_ts;
|
return this._eventEntry.event.origin_server_ts;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue