Add customisation point for mxid display (#7595)
* add wrapping component for hiding UI Signed-off-by: Kerry Archibald <kerrya@element.io> * add Setting Signed-off-by: Kerry Archibald <kerrya@element.io> * apply setting to profile settings, user menu, invite dialog, userinfo Signed-off-by: Kerry Archibald <kerrya@element.io> * hide mxids in user autocomplete * remove mxids from title in memeber list and timeline Signed-off-by: Kerry Archibald <kerrya@element.io> * hide mxid in ConfirmUserActionDialog Signed-off-by: Kerry Archibald <kerrya@element.io> * use name in power level event message when displayMxids is falsy Signed-off-by: Kerry Archibald <kerrya@element.io> * add customisation point for mxid display Signed-off-by: Kerry Archibald <kerrya@element.io> * use userid customisation Signed-off-by: Kerry Archibald <kerrya@element.io> * use customisation in sender profile Signed-off-by: Kerry Archibald <kerrya@element.io> * hide profile settings mxid if falsy Signed-off-by: Kerry Archibald <kerrya@element.io> * rename and move to components Signed-off-by: Kerry Archibald <kerrya@element.io> * remove change to UIFeature.ts Signed-off-by: Kerry Archibald <kerrya@element.io> * improvements from pr Signed-off-by: Kerry Archibald <kerrya@element.io> * lint fix Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
b481fc069e
commit
502b805164
15 changed files with 154 additions and 23 deletions
|
@ -44,6 +44,7 @@ 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';
|
||||
|
||||
export function getSenderName(event: MatrixEvent): string {
|
||||
return event.sender?.name ?? event.getSender() ?? _t("Someone");
|
||||
|
@ -499,6 +500,7 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
|
|||
if (users.indexOf(userId) === -1) users.push(userId);
|
||||
},
|
||||
);
|
||||
|
||||
const diffs = [];
|
||||
users.forEach((userId) => {
|
||||
// Previous power level
|
||||
|
@ -513,18 +515,20 @@ function textForPowerEvent(event: MatrixEvent): () => string | null {
|
|||
}
|
||||
if (from === previousUserDefault && to === currentUserDefault) { return; }
|
||||
if (to !== from) {
|
||||
diffs.push({ userId, from, to });
|
||||
const name = UserIdentifierCustomisations.getDisplayUserIdentifier(userId, { roomId: event.getRoomId() });
|
||||
diffs.push({ userId, name, from, to });
|
||||
}
|
||||
});
|
||||
if (!diffs.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// XXX: This is also surely broken for i18n
|
||||
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.userId,
|
||||
userId: diff.name,
|
||||
fromPowerLevel: Roles.textualPowerLevel(diff.from, previousUserDefault),
|
||||
toPowerLevel: Roles.textualPowerLevel(diff.to, currentUserDefault),
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue