Use display name instead of user ID when rendering power events (PSC-82) (#9295)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Johannes Marbach 2022-09-22 09:42:07 +02:00 committed by GitHub
parent 516b4f0ff8
commit 88c12cdaa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 42 deletions

View file

@ -43,7 +43,6 @@ import { MatrixClientPeg } from "./MatrixClientPeg";
import { ROOM_SECURITY_TAB } from "./components/views/dialogs/RoomSettingsDialog";
import AccessibleButton from './components/views/elements/AccessibleButton';
import RightPanelStore from './stores/right-panel/RightPanelStore';
import UserIdentifierCustomisations from './customisations/UserIdentifier';
import { ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload";
import { isLocationEvent } from './utils/EventUtils';
@ -55,7 +54,7 @@ function getRoomMemberDisplayname(event: MatrixEvent, userId = event.getSender()
const client = MatrixClientPeg.get();
const roomId = event.getRoomId();
const member = client.getRoom(roomId)?.getMember(userId);
return member?.rawDisplayName || userId || _t("Someone");
return member?.name || member?.rawDisplayName || userId || _t("Someone");
}
// These functions are frequently used just to check whether an event has
@ -467,7 +466,7 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
}
if (from === previousUserDefault && to === currentUserDefault) { return; }
if (to !== from) {
const name = UserIdentifierCustomisations.getDisplayUserIdentifier(userId, { roomId: event.getRoomId() });
const name = getRoomMemberDisplayname(event, userId);
diffs.push({ userId, name, from, to });
}
});