Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/TextForEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
},
);

const diffs = [];
const diffs: {displayName: string, from: number, to: number}[] = [];
users.forEach((userId) => {
// Previous power level
let from = event.getPrevContent().users[userId];
Expand All @@ -469,10 +469,10 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
if (!Number.isInteger(to)) {
to = currentUserDefault;
}
const displayName = MatrixClientPeg.get().getUser(userId).displayName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Displaynames are per-room, not global, so you can't use the displayName of getUser in a room. You'll need to get the room member instead

if (from === previousUserDefault && to === currentUserDefault) { return; }
if (to !== from) {
const name = UserIdentifierCustomisations.getDisplayUserIdentifier(userId, { roomId: event.getRoomId() });
diffs.push({ userId, name, from, to });
diffs.push({ displayName, from, to });
}
});
if (!diffs.length) {
Expand All @@ -483,8 +483,8 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
return () => _t('%(senderName)s changed the power level of %(powerLevelDiffText)s.', {
senderName,
powerLevelDiffText: diffs.map(diff =>
_t('%(userId)s from %(fromPowerLevel)s to %(toPowerLevel)s', {
userId: diff.name,
_t('%(displayName)s from %(fromPowerLevel)s to %(toPowerLevel)s', {
displayName: diff.displayName,
Comment on lines +486 to +487
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run the i18n script to regen the i18n files

fromPowerLevel: Roles.textualPowerLevel(diff.from, previousUserDefault),
toPowerLevel: Roles.textualPowerLevel(diff.to, currentUserDefault),
}),
Expand Down