-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
!fix: track DOM elements in useChatMessagesDomElements
with pagination
#113
Conversation
Renamed the state for clarity, as it stores an array of DOM elements.
Set the initial value of the state `domElements` to an empty array for consistency with its declared type. This ensures the hook returns a more appropriate value(an empty array) when no message IDs are passed.
The `useChatMessagesDomElements` hook was expecting all DOM elements from the rendered chat messages to be sent in a single event. However, due to the pagination mechanism in the bbb-core, only messages from the same page are sent together, which caused DOM elements from the last rendered page to overwrite those from previous pages. This commit adds support for pagination when storing DOM elements, ensuring that elements from different pages do not overwrite each other. It also includes a cleanup mechanism to remove stored DOM elements when a page is unmounted (due to pagination rolling or chat toggling). This ensures that only valid elements are stored and prevents the list from growing indefinitely. Additionally, the hook's internal state management has been updated and the filtering for the requested message IDs has been moved to the render function to ensure that the returned DOM elements are correctly updated when message IDs passed via props change.
Removes the `messageIdsState` as the hook already reacts to the message IDs passed via props, making the internal state redundant.
Checks whether the page is valid before updating state. Also, fixes a state update that was not using the proper set state function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to break the samples using the useChatMessageDomElements
.
Can you please double check if they are working, and add evidences to PR?
Actually, the PR does not break the examples using the |
published in [email protected] ! |
Updates the plugins SDK to version 0.0.64 based on the discussion in pull request bigbluebutton#113: bigbluebutton/bigbluebutton-html-plugin-sdk#113 (comment)
Updates the plugins SDK to version 0.0.64 based on the discussion in pull request: bigbluebutton/bigbluebutton-html-plugin-sdk#113 (comment)
What does this PR do?
The
useChatMessagesDomElements
hook was designed to expect all DOM elements from the rendered chat messages to be sent in a single event. However, due to the pagination mechanism in the bbb-core, only messages from the same page are sent together, which caused DOM elements from the last rendered page to overwrite those from previous pages.This PR introduces support for pagination when storing DOM elements, ensuring that elements from different pages do not overwrite each other. It also includes a cleanup mechanism to remove stored DOM elements when a page is unmounted (due to pagination rolling or chat toggling). This ensures that only valid elements are stored and prevents the list from growing indefinitely.
Additionally, the hook's internal state management has been updated and the filtering for the requested message IDs has been moved to the render function to ensure that the returned DOM elements are correctly updated when message IDs passed via props change.
Breaking change: Modified the structure of data exchanged in window events
UpdatedEventDetailsForChatMessageDomElements
.Closes Issue(s)
Closes #111
Note for reviewer
useLoadedChatMessages
hook, which is not returning all loaded message IDs in such cases and should be addressed in a separate issue/PR.useLoadedChatMessages
and then requests some of those IDs touseChatMessagesDomElements
.useLoadedChatMessages
is returning all IDs correctly.More
Relate bbb core PR: bigbluebutton/bigbluebutton#21176