Improved way to retrieve event sender for thread summary (#7732)
This commit is contained in:
parent
773c7f46b7
commit
af0b21de9d
1 changed files with 18 additions and 14 deletions
|
@ -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>
|
||||
) }
|
||||
</>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue