diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index b13eba33e470..d0355862e39b 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -476,6 +476,7 @@ export class UnwrappedEventTile extends React.Component { const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); room?.off(ThreadEvent.New, this.onNewThread); + room?.off(ThreadEvent.Delete, this.onThreadDeleted); if (this.threadState) { this.threadState.off(NotificationStateEvents.Update, this.onThreadStateUpdate); } @@ -494,6 +495,16 @@ export class UnwrappedEventTile extends React.Component { this.updateThread(thread); const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); room.off(ThreadEvent.New, this.onNewThread); + room.on(ThreadEvent.Delete, this.onThreadDeleted); + } + }; + + private onThreadDeleted = (thread: Thread) => { + if (thread.id === this.props.mxEvent.getId()) { + this.updateThread(thread); + const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); + room.on(ThreadEvent.New, this.onNewThread); + room.off(ThreadEvent.Delete, this.onThreadDeleted); } };