Skip to content

Commit

Permalink
Merge branch 'fix-text-area-disabled-bug' of github.com:yaminmomo15/r…
Browse files Browse the repository at this point in the history
…eact-chatbotify into fix-text-area-disabled-bug
  • Loading branch information
yaminmomo15 committed Oct 12, 2024
2 parents 574a8ff + d7ba632 commit c6cee87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/ChatBotBody/ChatBotBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ChatBotBody = ({
isBotTyping,
isLoadingChatHistory,
setIsLoadingChatHistory,
setIsChatHistoryLoaded,
isScrolling,
setIsScrolling,
setUnreadCount
Expand Down Expand Up @@ -99,6 +100,7 @@ const ChatBotBody = ({
const scrollDifference = scrollHeight - chatScrollHeight;
chatBodyRef.current.scrollTop = chatBodyRef.current.scrollTop + scrollDifference;
setIsLoadingChatHistory(false);
setIsChatHistoryLoaded(true);
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/context/BotStatesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export type BotStatesContextType = {
notificationsToggledOn: boolean;
setNotificationsToggledOn: Dispatch<SetStateAction<boolean>>;

isChatHistoryLoaded: boolean;
setIsChatHistoryLoaded: Dispatch<SetStateAction<boolean>>;

isLoadingChatHistory: boolean;
setIsLoadingChatHistory: Dispatch<SetStateAction<boolean>>;

Expand Down Expand Up @@ -78,6 +81,7 @@ const BotStatesProvider = ({
const [notificationsToggledOn, setNotificationsToggledOn] = useState<boolean>(
settings?.notification?.defaultToggledOn ?? true
);
const [isChatHistoryLoaded, setIsChatHistoryLoaded] = useState<boolean>(false);
const [isLoadingChatHistory, setIsLoadingChatHistory] = useState<boolean>(false);
const [isScrolling, setIsScrolling] = useState<boolean>(false);
const [textAreaDisabled, setTextAreaDisabled] = useState<boolean>(true);
Expand Down Expand Up @@ -107,6 +111,8 @@ const BotStatesProvider = ({
setVoiceToggledOn,
notificationsToggledOn,
setNotificationsToggledOn,
isChatHistoryLoaded,
setIsChatHistoryLoaded,
isLoadingChatHistory,
setIsLoadingChatHistory,
isScrolling,
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/internal/useBotEffectsInternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const useBotEffectInternal = () => {

// handles bot states
const {
isChatHistoryLoaded,
isChatWindowOpen,
isBotTyping,
isScrolling,
Expand Down Expand Up @@ -120,6 +121,11 @@ export const useBotEffectInternal = () => {
}, 1)
}, [])

// enables text area when chat history is loaded
useEffect(() => {
setTextAreaDisabled(settings.chatInput?.disabled as boolean);
}, [isChatHistoryLoaded])

// renders chat history button if enabled and triggers update if chat history configurations change
useEffect(() => {
if (settings.chatHistory?.disabled) {
Expand Down

0 comments on commit c6cee87

Please sign in to comment.