Consolidate TileShape into TimelineRenderingType (#7843)

This commit is contained in:
Michael Telatynski 2022-02-18 15:56:05 +00:00 committed by GitHub
parent ca89d3b96e
commit 5f5bb4a4fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 174 additions and 154 deletions

View file

@ -24,7 +24,7 @@ import { getUserNameColorClass } from '../../../utils/FormattingUtils';
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import UserIdentifier from '../../../customisations/UserIdentifier';
import { TileShape } from '../rooms/EventTile';
import RoomContext, { TimelineRenderingType } from '../../../contexts/RoomContext';
import SettingsStore from "../../../settings/SettingsStore";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
@ -32,7 +32,6 @@ interface IProps {
mxEvent: MatrixEvent;
onClick?(): void;
enableFlair: boolean;
tileShape?: TileShape;
}
interface IState {
@ -121,41 +120,44 @@ export default class SenderProfile extends React.Component<IProps, IState> {
const displayName = member?.rawDisplayName || mxEvent.getSender() || "";
const mxid = member?.userId || mxEvent.getSender() || "";
if (msgtype === MsgType.Emote && this.props.tileShape !== TileShape.ThreadPanel) {
return null; // emote message must include the name so don't duplicate it
}
return <RoomContext.Consumer>
{ roomContext => {
if (msgtype === MsgType.Emote &&
roomContext.timelineRenderingType !== TimelineRenderingType.ThreadsList
) {
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 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(
this.state.userGroups, this.state.relatedGroups,
);
let flair;
if (this.props.enableFlair) {
const displayedGroups = this.getDisplayedGroups(
this.state.userGroups, this.state.relatedGroups,
);
flair = <Flair key='flair'
userId={mxEvent.getSender()}
groups={displayedGroups}
/>;
}
flair = <Flair key='flair' userId={mxEvent.getSender()} groups={displayedGroups} />;
}
return (
<div className="mx_SenderProfile" dir="auto" onClick={this.props.onClick}>
<span className={`mx_SenderProfile_displayName ${colorClass}`}>
{ displayName }
</span>
{ mxidElement }
{ flair }
</div>
);
return (
<div className="mx_SenderProfile" dir="auto" onClick={this.props.onClick}>
<span className={`mx_SenderProfile_displayName ${colorClass}`}>
{ displayName }
</span>
{ mxidElement }
{ flair }
</div>
);
} }
</RoomContext.Consumer>;
}
}