Improved way to retrieve event sender for thread summary (#7732)

pull/21833/head
Germain 2022-02-08 12:08:47 +00:00 committed by GitHub
parent 773c7f46b7
commit af0b21de9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 14 deletions

View File

@ -360,6 +360,7 @@ interface IState {
thread: Thread;
threadReplyCount: number;
threadLastReply: MatrixEvent;
threadLastSender: RoomMember | null;
threadNotification?: NotificationCountType;
}
@ -408,6 +409,7 @@ export default class EventTile extends React.Component<IProps, IState> {
thread,
threadReplyCount: thread?.length,
threadLastReply: thread?.replyToEvent,
threadLastSender: thread?.replyToEvent.sender,
};
// don't do RR animations until we are mounted
@ -562,6 +564,7 @@ export default class EventTile extends React.Component<IProps, IState> {
this.setState({
threadLastReply: thread?.replyToEvent,
threadLastSender: thread?.replyToEvent?.sender,
threadReplyCount: thread?.length,
thread,
});
@ -659,23 +662,24 @@ export default class EventTile extends React.Component<IProps, IState> {
private renderThreadLastMessagePreview(): JSX.Element | null {
const { threadLastReply } = this.state;
if (!threadLastReply) {
return null;
}
const threadMessagePreview = MessagePreviewStore.instance.generatePreviewForEvent(threadLastReply);
if (!threadMessagePreview || !threadLastReply.sender) {
return null;
}
const sender = this.thread.roomState.getSentinelMember(threadLastReply.getSender());
return <>
<MemberAvatar member={threadLastReply.sender} width={24} height={24} className="mx_ThreadInfo_avatar" />
<div className="mx_ThreadInfo_content">
<span className="mx_ThreadInfo_message-preview">
{ threadMessagePreview }
</span>
</div>
<MemberAvatar
member={sender}
fallbackUserId={threadLastReply.getSender()}
width={24}
height={24}
className="mx_ThreadInfo_avatar"
/>
{ threadMessagePreview && (
<div className="mx_ThreadInfo_content">
<span className="mx_ThreadInfo_message-preview">
{ threadMessagePreview }
</span>
</div>
) }
</>;
}