mirror of https://github.com/vector-im/riot-web
Fix desktop notifications for invites showing user IDs instead of displaynames (#7780)
parent
15a9303d29
commit
c3bb8cf3ef
|
@ -51,6 +51,13 @@ export function getSenderName(event: MatrixEvent): string {
|
||||||
return event.sender?.name ?? event.getSender() ?? _t("Someone");
|
return event.sender?.name ?? event.getSender() ?? _t("Someone");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRoomMemberDisplayname(event: MatrixEvent, userId = event.getSender()): string {
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
const roomId = event.getRoomId();
|
||||||
|
const member = client.getRoom(roomId)?.getMember(userId);
|
||||||
|
return member?.rawDisplayName || userId || _t("Someone");
|
||||||
|
}
|
||||||
|
|
||||||
// These functions are frequently used just to check whether an event has
|
// These functions are frequently used just to check whether an event has
|
||||||
// any text to display at all. For this reason they return deferred values
|
// any text to display at all. For this reason they return deferred values
|
||||||
// to avoid the expense of looking up translations when they're not needed.
|
// to avoid the expense of looking up translations when they're not needed.
|
||||||
|
@ -77,8 +84,8 @@ function textForCallInviteEvent(event: MatrixEvent): () => string | null {
|
||||||
|
|
||||||
function textForMemberEvent(ev: MatrixEvent, allowJSX: boolean, showHiddenEvents?: boolean): () => string | null {
|
function textForMemberEvent(ev: MatrixEvent, allowJSX: boolean, showHiddenEvents?: boolean): () => string | null {
|
||||||
// XXX: SYJS-16 "sender is sometimes null for join messages"
|
// XXX: SYJS-16 "sender is sometimes null for join messages"
|
||||||
const senderName = getSenderName(ev);
|
const senderName = ev.sender?.name || getRoomMemberDisplayname(ev);
|
||||||
const targetName = ev.target ? ev.target.name : ev.getStateKey();
|
const targetName = ev.target?.name || getRoomMemberDisplayname(ev, ev.getStateKey());
|
||||||
const prevContent = ev.getPrevContent();
|
const prevContent = ev.getPrevContent();
|
||||||
const content = ev.getContent();
|
const content = ev.getContent();
|
||||||
const reason = content.reason;
|
const reason = content.reason;
|
||||||
|
|
Loading…
Reference in New Issue