Improve thread partitioning for 2nd degree relations (#7748)

This commit is contained in:
Germain 2022-02-10 15:18:55 +00:00 committed by GitHub
parent 87ca70edb1
commit 15a9303d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 17 deletions

View file

@ -649,13 +649,13 @@ export default class EventTile extends React.Component<IProps, IState> {
}
private renderThreadPanelSummary(): JSX.Element | null {
if (!this.thread) {
if (!this.state.thread) {
return null;
}
return <div className="mx_ThreadPanel_replies">
<span className="mx_ThreadPanel_repliesSummary">
{ this.thread.length }
{ this.state.thread.length }
</span>
{ this.renderThreadLastMessagePreview() }
</div>;
@ -665,7 +665,7 @@ export default class EventTile extends React.Component<IProps, IState> {
const { threadLastReply } = this.state;
const threadMessagePreview = MessagePreviewStore.instance.generatePreviewForEvent(threadLastReply);
const sender = this.thread.roomState.getSentinelMember(threadLastReply.getSender());
const sender = this.state.thread?.roomState.getSentinelMember(threadLastReply.getSender());
return <>
<MemberAvatar
member={sender}
@ -689,7 +689,7 @@ export default class EventTile extends React.Component<IProps, IState> {
return (
<p className="mx_ThreadSummaryIcon">{ _t("From a thread") }</p>
);
} else if (this.state.threadReplyCount) {
} else if (this.state.threadReplyCount && this.props.mxEvent.isThreadRoot) {
return (
<CardContext.Consumer>
{ context =>
@ -1092,11 +1092,10 @@ export default class EventTile extends React.Component<IProps, IState> {
return this.props.getRelationsForEvent(eventId, "m.annotation", "m.reaction");
};
private onReactionsCreated = (relationType: string, eventType: string) => {
private onReactionsCreated = (relationType: string, eventType: string): void => {
if (relationType !== "m.annotation" || eventType !== "m.reaction") {
return;
}
this.props.mxEvent.removeListener("Event.relationsCreated", this.onReactionsCreated);
this.setState({
reactions: this.getReactions(),
});