Repository navigation
feat: real-time thread synchronization and event listeners (#1350) - #1407
Open
Diwaspant132 wants to merge 1 commit into
Open
Diwaspant132 wants to merge 1 commit into
Diwaspant132 wants to merge 1 commit into
Conversation
…t#1350) - Add real-time thread message and thread delete event listeners to EmbeddedChatApi (resolves line 239 TODO) - Dispatch incoming thread replies (tmid) to onThreadMessageCallbacks and thread deletes to onThreadMessageDeleteCallbacks - Synchronize thread reply counts (tcount), last reply timestamps (tlm), and participant arrays (replies) in messageStore in real time - Handle thread message deletion by decrementing parent tcount and active threadMainMessage tcount - Automatically close active thread modal and reset threadMessages when parent message is deleted - Synchronize message edits across messages, threadMessages, and threadMainMessage in replaceMessage - Prevent thread replies from falsely triggering the main channel unread pill in ChatBody - Add unit test suite with 100% pass rate validating real-time thread state transitions Signed-off-by: Diwaspant132 <diwaspanta132@gmail.com>
Author
|
@Aryan-Verma-999 can u review this pr |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses #1350 and resolves the longstanding
TODOat line 239 inEmbeddedChatApi.ts.Previously, thread metrics (
tcount,tlm, andreplies) were not synchronized to parent messages instate.messagesin real time. When another user replied to a thread, the thread reply counter and metrics button (BubbleThreadBtn/MessageMetrics) on the parent message in the main channel would not appear or update without a full browser reload. Additionally, deleting thread messages failed to decrement parent counters, deleting parent messages left orphaned thread panes on screen, and thread replies falsely triggered the main channel unread message indicator.This PR introduces real-time thread event listeners in
@embeddedchat/apiand unifies thread state synchronization across@embeddedchat/react.Key Changes
@embeddedchat/api(EmbeddedChatApi.ts):onThreadMessageCallbacksandonThreadMessageDeleteCallbacksarrays.addThreadMessageListener,removeThreadMessageListener,addThreadMessageDeleteListener, andremoveThreadMessageDeleteListener.stream-room-messageswithtmidfiltering andnotify-room deleteMessagewith thread dispatching.catch (error: any)at line 195.@embeddedchat/react(messageStore.js):upsertMessage: Synchronizes parenttcount,tlm, andrepliesinstate.messagesin real time; keepsthreadMainMessagesynced when open.removeMessage: Decrements parenttcountwhen a thread message is removed; closes active thread modal (isThreadOpen: false, threadMainMessage: null, threadMessages: []) when parent is deleted.replaceMessage: Concurrently synchronizes edits acrossmessages,threadMessages, andthreadMainMessage.ChatBody.js:!message.tmidcheck to avoid thread replies falsely triggering the main scroll-down unread banner.Unit Tests (
packages/react/src/store/messageStore.test.mjs):Verification
yarn --cwd packages/react test: 6/6 tests passing (230ms).yarn --cwd packages/api build: Rollup & TypeScript declarations (dist/index.d.ts) compile cleanly with 0 errors.yarn format:check: 100% Prettier compliant.yarn --cwd packages/react lint: 0 errors.Fixes #1350