fix(bot): 🐛 Avoid chat to start multiple times
This commit is contained in:
@ -44,6 +44,7 @@ export const ConversationContainer = ({
|
|||||||
const { updateVariables } = useAnswers()
|
const { updateVariables } = useAnswers()
|
||||||
const bottomAnchor = useRef<HTMLDivElement | null>(null)
|
const bottomAnchor = useRef<HTMLDivElement | null>(null)
|
||||||
const scrollableContainer = useRef<HTMLDivElement | null>(null)
|
const scrollableContainer = useRef<HTMLDivElement | null>(null)
|
||||||
|
const [hasStarted, setHasStarted] = useState(false)
|
||||||
|
|
||||||
const displayNextGroup = ({
|
const displayNextGroup = ({
|
||||||
edgeId,
|
edgeId,
|
||||||
@ -90,6 +91,7 @@ export const ConversationContainer = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (hasStarted) return
|
||||||
if (
|
if (
|
||||||
isDefined(predefinedVariables) &&
|
isDefined(predefinedVariables) &&
|
||||||
Object.keys(predefinedVariables).length > 0
|
Object.keys(predefinedVariables).length > 0
|
||||||
@ -97,6 +99,7 @@ export const ConversationContainer = ({
|
|||||||
const prefilledVariables = injectPredefinedVariables(predefinedVariables)
|
const prefilledVariables = injectPredefinedVariables(predefinedVariables)
|
||||||
updateVariables(prefilledVariables)
|
updateVariables(prefilledVariables)
|
||||||
}
|
}
|
||||||
|
setHasStarted(true)
|
||||||
displayNextGroup({
|
displayNextGroup({
|
||||||
edgeId: startGroupId
|
edgeId: startGroupId
|
||||||
? undefined
|
? undefined
|
||||||
|
Reference in New Issue
Block a user