Skip to content

feat(api): implement thread message event listener callbacks - #1408

Open
swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1350-thread-message-event-listeners
Open

swarnendusahu10-dotcom wants to merge 1 commit into
RocketChat:developfrom
swarnendusahu10-dotcom:fix/issue-1350-thread-message-event-listeners

Conversation

@swarnendusahu10-dotcom

Copy link
Copy Markdown
Contributor

Description

Closes #1350

Implements the thread message event listener system in EmbeddedChatApi.ts, fulfilling the long-standing TODO at line 239 which marked this as pending after thread UI implementation.

Problem

When a user sends a reply inside an open thread, the message arrives over the DDP room-messages stream carrying a tmid (thread message ID) field pointing to its parent. Previously, no code dispatched these messages to thread-specific listeners — the onThreadMessageCallbacks array was declared but never populated or fired. As a result, the thread panel could not receive real-time updates and users had to manually refresh to see new replies.

Changes Made

File modified: packages/api/src/EmbeddedChatApi.ts (1 file, 27 lines added, 1 deleted)

  • Added onThreadMessageCallbacks property (typed identically to onMessageCallbacks).
  • Initialized to [] in the constructor.
  • In the room-messages DDP stream handler: when a normalized message has a truthy tmid, all registered thread listeners are called.
  • Same tmid guard added to the notify-user/message stream (covers action-block messages sent inside threads).
  • Added addThreadMessageListener() and removeThreadMessageListener() following the exact dedup/filter pattern used by every other listener type in this class.
  • Removed the resolved TODO comment.

Verification

  • All 10 edge-case scenarios pass (normal vs thread messages, dedup, removal, null safety, falsy tmid, listener leak prevention).
  • Rollup build of packages/api succeeds with no TypeScript errors.
  • Full packages/react build also succeeds with no warnings attributable to this change.
  • Zero changes to any React component, store, or other file — no domino effects.

This branch has not been deployed

No deployments
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.

Implement thread message event listeners

1 participant