mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-30 02:53:04 +00:00
Show room context details in forward dialog (#7162)
This commit is contained in:
committed by
GitHub
parent
14b5ed01d3
commit
cdbe25bd36
+24
-2
@@ -18,6 +18,9 @@ import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
import { MatrixClientPeg } from './MatrixClientPeg';
|
||||
import AliasCustomisations from './customisations/Alias';
|
||||
import DMRoomMap from "./utils/DMRoomMap";
|
||||
import SpaceStore from "./stores/spaces/SpaceStore";
|
||||
import { _t } from "./languageHandler";
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* Marks or unmarks the given room as being as a DM room.
|
||||
* @param {string} roomId The ID of the room to modify
|
||||
* @param {string} userId The user ID of the desired DM
|
||||
room target user or null to un-mark
|
||||
this room as a DM room
|
||||
room target user or null to un-mark
|
||||
this room as a DM room
|
||||
* @returns {object} A promise
|
||||
*/
|
||||
export async function setDMRoom(roomId: string, userId: string): Promise<void> {
|
||||
@@ -153,3 +156,22 @@ function guessDMRoomTargetId(room: Room, myUserId: string): string {
|
||||
if (oldestUser === undefined) return myUserId;
|
||||
return oldestUser.userId;
|
||||
}
|
||||
|
||||
export function roomContextDetailsText(room: Room): string {
|
||||
if (room.isSpaceRoom()) return undefined;
|
||||
|
||||
const dmPartner = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||
if (dmPartner) {
|
||||
return room.getMember(dmPartner)?.rawDisplayName;
|
||||
}
|
||||
|
||||
const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
|
||||
if (parent) {
|
||||
return _t("%(spaceName)s and %(count)s others", {
|
||||
spaceName: room.client.getRoom(parent).name,
|
||||
count: otherParents.length,
|
||||
});
|
||||
}
|
||||
|
||||
return room.getCanonicalAlias();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user