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