You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
!fix: track DOM elements in useChatMessagesDomElements with pagination (#113)
* refactor: rename state in useChatMessageDomElements hook
Renamed the state for clarity, as it stores an array of DOM elements.
* fix: initial value of useChatMessageDomElements
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.
* fix: track DOM elemnts in `useChatMessagesDomElements` with pagination
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.
* fix: remove `messageIdsState` from `useChatMessageDomElements`
Removes the `messageIdsState` as the hook already reacts to the message
IDs passed via props, making the internal state redundant.
* fix: page check and state update
Checks whether the page is valid before updating state. Also, fixes a
state update that was not using the proper set state function.
0 commit comments