diff --git a/src/components/structures/ThreadView.tsx b/src/components/structures/ThreadView.tsx index a59e93dda12..b0c35ef65f9 100644 --- a/src/components/structures/ThreadView.tsx +++ b/src/components/structures/ThreadView.tsx @@ -116,22 +116,12 @@ export default class ThreadView extends React.Component { this.setupThread(this.props.mxEvent); this.dispatcherRef = dis.register(this.onAction); - const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); - - if (!room) { - throw new Error( - `Unable to find room ${this.props.mxEvent.getRoomId()} for thread ${this.props.mxEvent.getId()}`, - ); - } - - room.on(ThreadEvent.New, this.onNewThread); + this.props.room.on(ThreadEvent.New, this.onNewThread); } public componentWillUnmount(): void { if (this.dispatcherRef) dis.unregister(this.dispatcherRef); const roomId = this.props.mxEvent.getRoomId(); - const room = MatrixClientPeg.get().getRoom(roomId); - room?.removeListener(ThreadEvent.New, this.onNewThread); SettingsStore.unwatchSetting(this.layoutWatcherRef); const hasRoomChanged = SdkContextClass.instance.roomViewStore.getRoomId() !== roomId; @@ -147,6 +137,10 @@ export default class ThreadView extends React.Component { action: Action.ViewThread, thread_id: null, }); + + this.state.thread?.off(ThreadEvent.NewReply, this.updateThreadRelation); + this.props.room.off(RoomEvent.LocalEchoUpdated, this.updateThreadRelation); + this.props.room.removeListener(ThreadEvent.New, this.onNewThread); } public componentDidUpdate(prevProps: IProps): void { diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index 488c699aed6..fa4008e1442 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -294,6 +294,9 @@ export default class TextualBody extends React.Component { this.unmounted = true; unmountPills(this.pills); unmountTooltips(this.tooltips); + + this.pills = []; + this.tooltips = []; } public shouldComponentUpdate(nextProps: Readonly, nextState: Readonly): boolean {