Use styled mxids in member list (#6328)
* Add DisambiguatedProfile Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Give DisambiguatedProfile some nice options Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Delint Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Use DisambiguatedProfile in member tile Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Basic handling of text overflow Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Use name instead of rawDisplayName Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * This seems to make more sense Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Reodred Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * rethemedex Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix import Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Fix color Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Appease the linter * Re-apply UserIdentifier patch Co-authored-by: Matthew Hodgson <matthew@matrix.org> Co-authored-by: Travis Ralston <travisr@matrix.org>
This commit is contained in:
parent
e55136cede
commit
5d28e0533d
12 changed files with 136 additions and 50 deletions
|
@ -21,10 +21,9 @@ import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
|||
|
||||
import Flair from '../elements/Flair';
|
||||
import FlairStore from '../../../stores/FlairStore';
|
||||
import { getUserNameColorClass } from '../../../utils/FormattingUtils';
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
import UserIdentifier from '../../../customisations/UserIdentifier';
|
||||
import DisambiguatedProfile from "./DisambiguatedProfile";
|
||||
import RoomContext, { TimelineRenderingType } from '../../../contexts/RoomContext';
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
@ -106,9 +105,8 @@ export default class SenderProfile extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { mxEvent } = this.props;
|
||||
const colorClass = getUserNameColorClass(mxEvent.getSender());
|
||||
const { msgtype } = mxEvent.getContent();
|
||||
const { mxEvent, onClick } = this.props;
|
||||
const msgtype = mxEvent.getContent().msgtype;
|
||||
|
||||
let member = mxEvent.sender;
|
||||
if (SettingsStore.getValue("feature_use_only_current_profiles")) {
|
||||
|
@ -118,10 +116,6 @@ export default class SenderProfile extends React.Component<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
const disambiguate = member?.disambiguate || mxEvent.sender?.disambiguate;
|
||||
const displayName = member?.rawDisplayName || mxEvent.getSender() || "";
|
||||
const mxid = member?.userId || mxEvent.getSender() || "";
|
||||
|
||||
return <RoomContext.Consumer>
|
||||
{ roomContext => {
|
||||
if (msgtype === MsgType.Emote &&
|
||||
|
@ -130,17 +124,6 @@ export default class SenderProfile extends React.Component<IProps, IState> {
|
|||
return null; // emote message must include the name so don't duplicate it
|
||||
}
|
||||
|
||||
let mxidElement;
|
||||
if (disambiguate) {
|
||||
mxidElement = (
|
||||
<span className="mx_SenderProfile_mxid">
|
||||
{ UserIdentifier.getDisplayUserIdentifier(
|
||||
mxid, { withDisplayName: true, roomId: mxEvent.getRoomId() },
|
||||
) }
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
let flair;
|
||||
if (this.props.enableFlair) {
|
||||
const displayedGroups = this.getDisplayedGroups(
|
||||
|
@ -151,13 +134,14 @@ export default class SenderProfile extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="mx_SenderProfile" dir="auto" onClick={this.props.onClick}>
|
||||
<span className={`mx_SenderProfile_displayName ${colorClass}`}>
|
||||
{ displayName }
|
||||
</span>
|
||||
{ mxidElement }
|
||||
{ flair }
|
||||
</div>
|
||||
<DisambiguatedProfile
|
||||
fallbackName={mxEvent.getSender() || ""}
|
||||
flair={flair}
|
||||
onClick={onClick}
|
||||
member={member}
|
||||
colored={true}
|
||||
emphasizeDisplayName={true}
|
||||
/>
|
||||
);
|
||||
} }
|
||||
</RoomContext.Consumer>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue