Merge pull request #398 from MidhunSureshR/fix-397
Support removing display names in RoomMemberTile
This commit is contained in:
commit
197c247044
1 changed files with 29 additions and 1 deletions
|
@ -33,7 +33,10 @@ export class RoomMemberTile extends SimpleTile {
|
||||||
if (content.avatar_url !== prevContent.avatar_url) {
|
if (content.avatar_url !== prevContent.avatar_url) {
|
||||||
return `${senderName} changed their avatar`;
|
return `${senderName} changed their avatar`;
|
||||||
} else if (content.displayname !== prevContent.displayname) {
|
} else if (content.displayname !== prevContent.displayname) {
|
||||||
return `${prevContent.displayname} changed their name to ${content.displayname}`;
|
if (!content.displayname) {
|
||||||
|
return `${stateKey} removed their name (${prevContent.displayname})`;
|
||||||
|
}
|
||||||
|
return `${prevContent.displayname ?? stateKey} changed their name to ${content.displayname}`;
|
||||||
}
|
}
|
||||||
} else if (membership === "join") {
|
} else if (membership === "join") {
|
||||||
return `${targetName} joined the room`;
|
return `${targetName} joined the room`;
|
||||||
|
@ -59,3 +62,28 @@ export class RoomMemberTile extends SimpleTile {
|
||||||
return `${sender} membership changed to ${content.membership}`;
|
return `${sender} membership changed to ${content.membership}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function tests() {
|
||||||
|
return {
|
||||||
|
"user removes display name": (assert) => {
|
||||||
|
const tile = new RoomMemberTile({
|
||||||
|
entry: {
|
||||||
|
prevContent: {displayname: "foo", membership: "join"},
|
||||||
|
content: {membership: "join"},
|
||||||
|
stateKey: "foo@bar.com",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.strictEqual(tile.announcement, "foo@bar.com removed their name (foo)");
|
||||||
|
},
|
||||||
|
"user without display name sets a new display name": (assert) => {
|
||||||
|
const tile = new RoomMemberTile({
|
||||||
|
entry: {
|
||||||
|
prevContent: {membership: "join"},
|
||||||
|
content: {displayname: "foo", membership: "join" },
|
||||||
|
stateKey: "foo@bar.com",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.strictEqual(tile.announcement, "foo@bar.com changed their name to foo");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Reference in a new issue