Skip to content

Commit

Permalink
[Feat] 사용자가 5초간 움직임이 없을 시 Echo bot 활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
BangDori committed Aug 17, 2023
1 parent e2386f9 commit 82f3963
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/home/Chatbot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect } from 'react';
import { useLocation, useToggle } from 'react-use';
import { useIdle, useLocation, useToggle } from 'react-use';
import { useSelector } from 'react-redux';

import chatbotIcon from '@assets/util/chatbot.png';
Expand All @@ -20,6 +20,7 @@ import {
} from '@utils/chatbot';

const Chatbot = () => {
const isIdle = useIdle(5e3);
const { pathname } = useLocation();
const { message, isOverlay, isSelect, isEnd, isMore } = useSelector(
(state) => state.chatbot,
Expand All @@ -29,6 +30,12 @@ const Chatbot = () => {
const onStartChatbot = () => store.dispatch(onChatbot());
const onCloseChatbot = () => store.dispatch(endChatbot());

useEffect(() => {
if (isIdle) {
setIsShowMessage(true);
}
}, [setIsShowMessage, isIdle]);

useEffect(() => {
if (message === END_MESSAGE) {
setTimeout(() => {
Expand Down

0 comments on commit 82f3963

Please sign in to comment.