Mercurial
comparison love/epi/src/hooks/useComposer.ts @ 38:cf9caa4abc3e
[Love] FE and BE. Can chat and render images. Also created MCP for powerpoint generations.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 01 Dec 2025 20:35:56 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 37:fb9bcd3145cb | 38:cf9caa4abc3e |
|---|---|
| 1 import { useCallback } from 'react'; | |
| 2 import { useAtom } from 'jotai'; | |
| 3 import { composerTextAtom, composerStatusAtom } from '@/atoms/composerAtom'; | |
| 4 | |
| 5 export const useComposer = () => { | |
| 6 const [text, setText] = useAtom(composerTextAtom); | |
| 7 const [status, setStatus] = useAtom(composerStatusAtom); | |
| 8 | |
| 9 const setSending = useCallback(() => setStatus('sending' as const), [setStatus]); | |
| 10 const setIdle = useCallback(() => setStatus('idle' as const), [setStatus]); | |
| 11 const reset = useCallback(() => { | |
| 12 setText(''); | |
| 13 setIdle(); | |
| 14 }, [setText, setIdle]); | |
| 15 | |
| 16 const isSending = status === 'sending'; | |
| 17 const isEmpty = text.trim() === ''; | |
| 18 | |
| 19 return { | |
| 20 text, | |
| 21 setText, | |
| 22 status, | |
| 23 isSending, | |
| 24 isEmpty, | |
| 25 isDisabled: isEmpty && !isSending, | |
| 26 setSending, | |
| 27 setIdle, | |
| 28 reset, | |
| 29 }; | |
| 30 }; |