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

Commit cdbe25b

Browse files
authored
Show room context details in forward dialog (#7162)
1 parent 14b5ed0 commit cdbe25b

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

res/css/views/dialogs/_ForwardDialog.scss

+13-3
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,28 @@ limitations under the License.
110110
margin-right: 12px;
111111
}
112112

113-
.mx_ForwardList_entry_name {
114-
font-size: $font-15px;
113+
.mx_ForwardList_entry_name,
114+
.mx_ForwardList_entry_detail {
115115
line-height: 30px;
116116
overflow: hidden;
117117
white-space: nowrap;
118118
text-overflow: ellipsis;
119-
margin-right: 12px;
119+
}
120+
121+
.mx_ForwardList_entry_name {
122+
font-size: $font-15px;
123+
}
124+
125+
.mx_ForwardList_entry_detail {
126+
font-size: $font-12px;
127+
margin-left: 8px;
128+
color: $tertiary-content;
120129
}
121130
}
122131

123132
.mx_ForwardList_sendButton {
124133
position: relative;
134+
margin-left: 12px;
125135

126136
&:not(.mx_ForwardList_canSend) .mx_ForwardList_sendLabel {
127137
// Hide the "Send" label while preserving button size

src/Rooms.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { Room } from "matrix-js-sdk/src/models/room";
1818

1919
import { MatrixClientPeg } from './MatrixClientPeg';
2020
import AliasCustomisations from './customisations/Alias';
21+
import DMRoomMap from "./utils/DMRoomMap";
22+
import SpaceStore from "./stores/spaces/SpaceStore";
23+
import { _t } from "./languageHandler";
2124

2225
/**
2326
* Given a room object, return the alias we should use for it,
@@ -80,8 +83,8 @@ export function guessAndSetDMRoom(room: Room, isDirect: boolean): Promise<void>
8083
* Marks or unmarks the given room as being as a DM room.
8184
* @param {string} roomId The ID of the room to modify
8285
* @param {string} userId The user ID of the desired DM
83-
room target user or null to un-mark
84-
this room as a DM room
86+
room target user or null to un-mark
87+
this room as a DM room
8588
* @returns {object} A promise
8689
*/
8790
export async function setDMRoom(roomId: string, userId: string): Promise<void> {
@@ -153,3 +156,22 @@ function guessDMRoomTargetId(room: Room, myUserId: string): string {
153156
if (oldestUser === undefined) return myUserId;
154157
return oldestUser.userId;
155158
}
159+
160+
export function roomContextDetailsText(room: Room): string {
161+
if (room.isSpaceRoom()) return undefined;
162+
163+
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
164+
if (dmPartner) {
165+
return room.getMember(dmPartner)?.rawDisplayName;
166+
}
167+
168+
const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
169+
if (parent) {
170+
return _t("%(spaceName)s and %(count)s others", {
171+
spaceName: room.client.getRoom(parent).name,
172+
count: otherParents.length,
173+
});
174+
}
175+
176+
return room.getCanonicalAlias();
177+
}

src/components/views/dialogs/ForwardDialog.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import TruncatedList from "../elements/TruncatedList";
4444
import EntityTile from "../rooms/EntityTile";
4545
import BaseAvatar from "../avatars/BaseAvatar";
4646
import SpaceStore from "../../../stores/spaces/SpaceStore";
47+
import { roomContextDetailsText } from "../../../Rooms";
4748

4849
const AVATAR_SIZE = 30;
4950

@@ -121,6 +122,8 @@ const Entry: React.FC<IEntryProps> = ({ room, event, matrixClient: cli, onFinish
121122
/>;
122123
}
123124

125+
const detailsText = roomContextDetailsText(room);
126+
124127
return <div className="mx_ForwardList_entry">
125128
<AccessibleTooltipButton
126129
className="mx_ForwardList_roomButton"
@@ -131,6 +134,9 @@ const Entry: React.FC<IEntryProps> = ({ room, event, matrixClient: cli, onFinish
131134
>
132135
<DecoratedRoomAvatar room={room} avatarSize={32} />
133136
<span className="mx_ForwardList_entry_name">{ room.name }</span>
137+
{ detailsText && <span className="mx_ForwardList_entry_detail">
138+
{ detailsText }
139+
</span> }
134140
</AccessibleTooltipButton>
135141
<AccessibleTooltipButton
136142
kind={sendState === SendState.Failed ? "danger_outline" : "primary_outline"}

src/i18n/strings/en_EN.json

+3
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@
396396
"Failed to invite users to the room:": "Failed to invite users to the room:",
397397
"We sent the others, but the below people couldn't be invited to <RoomName/>": "We sent the others, but the below people couldn't be invited to <RoomName/>",
398398
"Some invites couldn't be sent": "Some invites couldn't be sent",
399+
"%(spaceName)s and %(count)s others|other": "%(spaceName)s and %(count)s others",
400+
"%(spaceName)s and %(count)s others|zero": "%(spaceName)s",
401+
"%(spaceName)s and %(count)s others|one": "%(spaceName)s and %(count)s other",
399402
"You need to be logged in.": "You need to be logged in.",
400403
"You need to be able to invite users to do that.": "You need to be able to invite users to do that.",
401404
"Unable to create widget.": "Unable to create widget.",

0 commit comments

Comments
 (0)