Skip to content

fix(react): close thread view when its parent message is deleted - #1368

Open
ishan-one8 wants to merge 1 commit into
RocketChat:developfrom
ishan-one8:fix/close-thread-on-parent-delete
Open

fix(react): close thread view when its parent message is deleted#1368
ishan-one8 wants to merge 1 commit into
RocketChat:developfrom
ishan-one8:fix/close-thread-on-parent-delete

Conversation

@ishan-one8

Copy link
Copy Markdown

Description

Fixes the state leak described in #1080. When the parent message of an open thread was deleted, messageStore.removeMessage removed the message from the main list (and from thread replies) but never checked whether the deleted message was the thread's threadMainMessage. As a result the Thread View stayed open, showing a stale copy of a message that no longer exists.

This updates removeMessage so that when the deleted message is the current threadMainMessage, the thread state is reset (isThreadOpen: false, threadMainMessage: null, threadMessages: []) in the same update — mirroring what closeThread already does. Since removeMessage is wired to the message-delete listener, this works for deletions from EmbeddedChat as well as from other clients.

Acceptance Criteria fulfillment

  • Deleting a thread's parent message now closes the Thread View
  • Thread state is cleared from the store when the parent is removed
  • Deleting an unrelated message leaves the open thread untouched (guarded by the threadMainMessage?._id === messageId check)

PR Test Details

  1. Open a chat, open a message's thread.
  2. Delete that parent message (from EmbeddedChat or another client).
  3. The parent disappears from the main list and the Thread View now closes automatically instead of showing stale data.

Fixes #1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Thread UI remains open after parent message is deleted (State Leak)

1 participant