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

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 committed Sep 1, 2022
1 parent 29f245c commit e4c4b73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/components/views/rooms/NewRoomIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ const NewRoomIntro = () => {
let body: JSX.Element;
if (dmPartner) {
let introMessage = _t("This is the beginning of your direct message history with <displayName/>.");
let caption: string;
let captionElement: JSX.Element = <></>;

if (isLocalRoom) {
introMessage = _t("Send your first message to invite <displayName/> to chat");
} else if ((room.getJoinedMemberCount() + room.getInvitedMemberCount()) === 2) {
caption = _t("Only the two of you are in this conversation, unless either of you invites anyone to join.");
captionElement = <p>
{ _t("Only the two of you are in this conversation, unless either of you invites anyone to join.") }
</p>;
}

const member = room?.getMember(dmPartner);
const displayName = room.name;
const displayName = room?.name || member?.rawDisplayName || dmPartner;
body = <React.Fragment>
<RoomAvatar
room={room}
Expand All @@ -87,7 +89,7 @@ const NewRoomIntro = () => {
<p>{ _t(introMessage, {}, {
displayName: () => <b>{ displayName }</b>,
}) }</p>
{ caption && <p>{ caption }</p> }
{ captionElement }
</React.Fragment>;
} else {
const inRoom = room && room.getMyMembership() === "join";
Expand Down
4 changes: 2 additions & 2 deletions test/components/views/rooms/NewRoomIntro-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("NewRoomIntro", () => {

it("should render the expected intro", () => {
const expected = `This is the beginning of your direct message history with test_room.`;
screen.getByText((id, element) => element.tagName === "SPAN" && element.textContent === expected);
screen.getByText((id, element) => element?.tagName === "SPAN" && element?.textContent === expected);
});
});

Expand All @@ -75,7 +75,7 @@ describe("NewRoomIntro", () => {

it("should render the expected intro", () => {
const expected = `Send your first message to invite test_room to chat`;
screen.getByText((id, element) => element.tagName === "SPAN" && element.textContent === expected);
screen.getByText((id, element) => element?.tagName === "SPAN" && element?.textContent === expected);
});
});
});

0 comments on commit e4c4b73

Please sign in to comment.