Skip to content

Commit

Permalink
refactor: Improve message streaming checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Nov 22, 2024
1 parent b7d2c9d commit ee6071e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/hooks/internal/useMessagesInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ export const useMessagesInternal = () => {
const message = {...createMessage(content, sender), id: streamMessageMap.current.get(sender) as string};
// handles chunk stream message event
if (settings.event?.rcbChunkStreamMessage) {
const event = await callRcbEvent(
RcbEvent.CHUNK_STREAM_MESSAGE,
{...message, id: streamMessageMap.current.get(sender)}
);
const event = await callRcbEvent(RcbEvent.CHUNK_STREAM_MESSAGE, message);
if (event.defaultPrevented) {
return null;
}
Expand All @@ -245,7 +242,7 @@ export const useMessagesInternal = () => {
const updatedMessages = [...prevMessages];

for (let i = updatedMessages.length - 1; i >= 0; i--) {
if (updatedMessages[i].sender === sender && typeof updatedMessages[i].content === typeof content) {
if (updatedMessages[i].id === message.id) {
updatedMessages[i] = message;
break;
}
Expand Down

0 comments on commit ee6071e

Please sign in to comment.