Skip to content

Commit

Permalink
chore: Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Sep 15, 2024
1 parent 77aa8d2 commit d142265
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/hooks/internal/useMessagesInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const useMessagesInternal = () => {
return updatedMessages;
});
return streamMessageMap.current.get(sender) || null;
}, []);
},[]);

/**
* Sets the streaming mode of the chatbot.
Expand All @@ -233,9 +233,12 @@ export const useMessagesInternal = () => {
return true;
}

const messageId = streamMessageMap.current.get(sender);
const messageToEndStreamFor = messages.find((message) => message.id === messageId);

// handles stop stream message event
if (settings.event?.rcbStopStreamMessage) {
const event = callRcbEvent(RcbEvent.STOP_STREAM_MESSAGE, {});
const event = callRcbEvent(RcbEvent.STOP_STREAM_MESSAGE, {messageToEndStreamFor});
if (event.defaultPrevented) {
return false;
}
Expand All @@ -245,7 +248,7 @@ export const useMessagesInternal = () => {
streamMessageMap.current.delete(sender);
saveChatHistory(messages);
return true;
}, [messages]);
}, [messages])

return {
endStreamMessage,
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/internal/useRcbEventInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { useCallback } from "react";
import { emitRcbEvent } from "../../services/RcbEventService";
import { usePaths } from "../usePaths";
import { useBotRefsContext } from "../../context/BotRefsContext";
import { useSettingsContext } from "../../context/SettingsContext";
import { useStylesContext } from "../../context/StylesContext";
import { useMessagesContext } from "../../context/MessagesContext";
import { RcbEvent } from "../../constants/RcbEvent";

/**
Expand Down

0 comments on commit d142265

Please sign in to comment.