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

Commit

Permalink
Invite dialog: display MXID on its own line (#11756)
Browse files Browse the repository at this point in the history
* Invite dialog: display MXID on its own line

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Refactor to satisfy i18n linter

Signed-off-by: Andrew Ferrazzutti <[email protected]>

---------

Signed-off-by: Andrew Ferrazzutti <[email protected]>
  • Loading branch information
AndrewFerr authored Aug 1, 2024
1 parent a38a516 commit 1270518
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 35 deletions.
4 changes: 4 additions & 0 deletions res/css/views/rooms/_RoomPreviewBar.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ a.mx_RoomPreviewBar_inviter {
cursor: pointer;
}

.mx_RoomPreviewBar_inviter_mxid {
color: var(--cpd-color-text-secondary);
}

.mx_RoomPreviewBar_icon {
margin-right: 8px;
vertical-align: text-top;
Expand Down
34 changes: 20 additions & 14 deletions src/components/views/rooms/RoomPreviewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -506,33 +506,39 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
break;
}
case MessageCase.Invite: {
const isDM = this.isDMInvite();
const avatar = <RoomAvatar room={this.props.room} oobData={this.props.oobData} />;

const inviteMember = this.getInviteMember();
let inviterElement: JSX.Element;
if (inviteMember) {
inviterElement = (
<span>
<span className="mx_RoomPreviewBar_inviter">{inviteMember.rawDisplayName}</span> (
{inviteMember.userId})
</span>
);
} else {
inviterElement = <span className="mx_RoomPreviewBar_inviter">{this.props.inviterName}</span>;
}
const userName = (
<span className="mx_RoomPreviewBar_inviter">
{inviteMember?.rawDisplayName ?? this.props.inviterName}
</span>
);
const inviterElement = (
<>
{isDM
? _t("room|dm_invite_subtitle", {}, { userName })
: _t("room|invite_subtitle", {}, { userName })}
{inviteMember && (
<>
<br />
<span className="mx_RoomPreviewBar_inviter_mxid">{inviteMember.userId}</span>
</>
)}
</>
);

const isDM = this.isDMInvite();
if (isDM) {
title = _t("room|dm_invite_title", {
user: inviteMember?.name ?? this.props.inviterName,
});
subTitle = [avatar, _t("room|dm_invite_subtitle", {}, { userName: () => inviterElement })];
primaryActionLabel = _t("room|dm_invite_action");
} else {
title = _t("room|invite_title", { roomName });
subTitle = [avatar, _t("room|invite_subtitle", {}, { userName: () => inviterElement })];
primaryActionLabel = _t("action|accept");
}
subTitle = [avatar, inviterElement];

const myUserId = MatrixClientPeg.safeGet().getSafeUserId();
const member = this.props.room?.currentState.getMember(myUserId);
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@
"invite_reject_ignore": "Reject & Ignore user",
"invite_sent_to_email": "This invite was sent to %(email)s",
"invite_sent_to_email_room": "This invite to %(roomName)s was sent to %(email)s",
"invite_subtitle": "<userName/> invited you",
"invite_subtitle": "Invited by <userName/>",
"invite_this_room": "Invite to this room",
"invite_title": "Do you want to join %(roomName)s?",
"inviter_unknown": "Unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ exports[`<RoomPreviewBar /> with an invite with an invited email when client has
</p>
<p>
<span>
Invited by
<span
class="mx_RoomPreviewBar_inviter"
>
@inviter:test.com
</span>
invited you
</span>
</p>
</div>
Expand Down Expand Up @@ -322,18 +322,19 @@ exports[`<RoomPreviewBar /> with an invite without an invited email for a dm roo
</p>
<p>
<span>
<span>
<span
class="mx_RoomPreviewBar_inviter"
>
@inviter:test.com name
</span>
(
@inviter:test.com
)
<span
class="mx_RoomPreviewBar_inviter"
>
@inviter:test.com name
</span>
wants to chat
</span>
<br />
<span
class="mx_RoomPreviewBar_inviter_mxid"
>
@inviter:test.com
</span>
</p>
</div>
`;
Expand Down Expand Up @@ -387,17 +388,18 @@ exports[`<RoomPreviewBar /> with an invite without an invited email for a non-dm
</p>
<p>
<span>
<span>
<span
class="mx_RoomPreviewBar_inviter"
>
@inviter:test.com name
</span>
(
@inviter:test.com
)
Invited by
<span
class="mx_RoomPreviewBar_inviter"
>
@inviter:test.com name
</span>
invited you
</span>
<br />
<span
class="mx_RoomPreviewBar_inviter_mxid"
>
@inviter:test.com
</span>
</p>
</div>
Expand Down

0 comments on commit 1270518

Please sign in to comment.