Fix issues with ThreadSummary in msc-enabled mode (#8018)

This commit is contained in:
Michael Telatynski 2022-03-10 13:34:24 +00:00 committed by GitHub
parent 225581de6a
commit 5902ddaf06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,11 +68,13 @@ const ThreadSummary = ({ mxEvent, thread }: IProps) => {
export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => { export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.lastReply()); const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.replyToEvent);
const preview = useAsyncMemo(async () => { const preview = useAsyncMemo(async () => {
if (!lastReply) return;
await cli.decryptEventIfNeeded(lastReply); await cli.decryptEventIfNeeded(lastReply);
return MessagePreviewStore.instance.generatePreviewForEvent(lastReply); return MessagePreviewStore.instance.generatePreviewForEvent(lastReply);
}, [lastReply]); }, [lastReply]);
if (!preview) return null;
const sender = thread.roomState.getSentinelMember(lastReply.getSender()); const sender = thread.roomState.getSentinelMember(lastReply.getSender());
return <> return <>
@ -83,13 +85,11 @@ export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
height={24} height={24}
className="mx_ThreadInfo_avatar" className="mx_ThreadInfo_avatar"
/> />
{ preview && ( <div className="mx_ThreadInfo_content">
<div className="mx_ThreadInfo_content"> <span className="mx_ThreadInfo_message-preview">
<span className="mx_ThreadInfo_message-preview"> { preview }
{ preview } </span>
</span> </div>
</div>
) }
</>; </>;
}; };