mirror of
https://github.com/langgenius/dify.git
synced 2025-07-07 17:23:22 +00:00
41 lines
976 B
TypeScript
41 lines
976 B
TypeScript
![]() |
import { useCallback, useState } from 'react'
|
||
|
import useFoldAnimInto from './use-fold-anim-into'
|
||
|
|
||
|
const useHideLogic = (onClose: () => void) => {
|
||
|
const {
|
||
|
modalClassName,
|
||
|
foldIntoAnim: doFoldAnimInto,
|
||
|
clearCountDown,
|
||
|
countDownFoldIntoAnim,
|
||
|
} = useFoldAnimInto(onClose)
|
||
|
|
||
|
const [isInstalling, doSetIsInstalling] = useState(false)
|
||
|
const setIsInstalling = useCallback((isInstalling: boolean) => {
|
||
|
if (!isInstalling)
|
||
|
clearCountDown()
|
||
|
doSetIsInstalling(isInstalling)
|
||
|
}, [clearCountDown])
|
||
|
|
||
|
const foldAnimInto = useCallback(() => {
|
||
|
if (isInstalling) {
|
||
|
doFoldAnimInto()
|
||
|
return
|
||
|
}
|
||
|
onClose()
|
||
|
}, [doFoldAnimInto, isInstalling, onClose])
|
||
|
|
||
|
const handleStartToInstall = useCallback(() => {
|
||
|
setIsInstalling(true)
|
||
|
countDownFoldIntoAnim()
|
||
|
}, [countDownFoldIntoAnim, setIsInstalling])
|
||
|
|
||
|
return {
|
||
|
modalClassName,
|
||
|
foldAnimInto,
|
||
|
setIsInstalling,
|
||
|
handleStartToInstall,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default useHideLogic
|