Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2a905dc

Browse files
committed
Use roon name for room intro
1 parent 380653f commit 2a905dc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/views/rooms/NewRoomIntro.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ const NewRoomIntro = () => {
5555
? room.targets[0]?.userId
5656
: DMRoomMap.shared().getUserIdForRoomId(roomId);
5757

58-
let body;
58+
let body: JSX.Element;
5959
if (dmPartner) {
6060
let introMessage = _t("This is the beginning of your direct message history with <displayName/>.");
61-
let caption;
61+
let caption: string;
6262

6363
if (isLocalRoom) {
6464
introMessage = _t("Send your first message to invite <displayName/> to chat");
@@ -67,7 +67,7 @@ const NewRoomIntro = () => {
6767
}
6868

6969
const member = room?.getMember(dmPartner);
70-
const displayName = member?.rawDisplayName || dmPartner;
70+
const displayName = room.name;
7171
body = <React.Fragment>
7272
<RoomAvatar
7373
room={room}

test/components/views/rooms/NewRoomIntro-test.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ describe("NewRoomIntro", () => {
5353
describe("for a DM Room", () => {
5454
beforeEach(() => {
5555
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(userId);
56-
renderNewRoomIntro(client, new Room(roomId, client, client.getUserId()));
56+
const room = new Room(roomId, client, client.getUserId());
57+
room.name = "test_room";
58+
renderNewRoomIntro(client, room);
5759
});
5860

5961
it("should render the expected intro", () => {
60-
const expected = `This is the beginning of your direct message history with ${userId}.`;
62+
const expected = `This is the beginning of your direct message history with test_room.`;
6163
screen.getByText((id, element) => element.tagName === "SPAN" && element.textContent === expected);
6264
});
6365
});
@@ -66,12 +68,13 @@ describe("NewRoomIntro", () => {
6668
beforeEach(() => {
6769
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(userId);
6870
const localRoom = new LocalRoom(roomId, client, client.getUserId());
71+
localRoom.name = "test_room";
6972
localRoom.targets.push(new DirectoryMember({ user_id: userId }));
7073
renderNewRoomIntro(client, localRoom);
7174
});
7275

7376
it("should render the expected intro", () => {
74-
const expected = `Send your first message to invite ${userId} to chat`;
77+
const expected = `Send your first message to invite test_room to chat`;
7578
screen.getByText((id, element) => element.tagName === "SPAN" && element.textContent === expected);
7679
});
7780
});

0 commit comments

Comments
 (0)