mirror of
https://github.com/langgenius/dify.git
synced 2026-07-22 19:48:36 +08:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
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,
|
|
foldIntoTaskTrigger: doFoldAnimInto,
|
|
setIsInstalling,
|
|
handleStartToInstall,
|
|
}
|
|
}
|
|
|
|
export default useHideLogic
|