From 3c1160542a18f34d409df365ff9a2580a8a0ea08 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Mon, 17 Oct 2022 12:26:22 +0200 Subject: [PATCH] properly listen to thread deletion --- src/components/views/rooms/EventTile.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index 654cc80b67d..db465c0df13 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); } };