@@ -20,11 +20,10 @@ import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime
2020import {
2121 CommonActions ,
2222 StackActions ,
23- useIsFocused ,
2423 useNavigation ,
2524 usePreventRemove ,
2625} from "@react-navigation/native" ;
27- import { useEffect , useEffectEvent , useLayoutEffect , useRef , useState } from "react" ;
26+ import { useEffect , useEffectEvent , useRef , useState } from "react" ;
2827import { Platform , Pressable , View } from "react-native" ;
2928import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView" ;
3029import { KeyboardController } from "react-native-keyboard-controller" ;
@@ -36,7 +35,6 @@ import {
3635} from "@t3tools/contracts" ;
3736
3837import { ComposerEditor , type ComposerEditorHandle } from "../../components/ComposerEditor" ;
39- import { submitComposer } from "../../state/submit-composer" ;
4038import { composerContextImportsAtom } from "../../state/use-composer-drafts" ;
4139import { abortComposerDraftOperations } from "../../state/composerDraftOperations" ;
4240import { composerContextSendBlockReason } from "../../lib/composerContext" ;
@@ -160,7 +158,6 @@ export function NewTaskDraftScreen(props: {
160158 const projects = useProjects ( ) ;
161159 const flow = useNewTaskFlow ( ) ;
162160 const navigation = useNavigation ( ) ;
163- const isScreenFocused = useIsFocused ( ) ;
164161 const goBack = useWorkspaceBackNavigation ( "threads" ) ;
165162 const {
166163 consumeShare,
@@ -808,48 +805,7 @@ export function NewTaskDraftScreen(props: {
808805 locked : isComposerInteractionLocked ,
809806 } ) ;
810807
811- const submissionOwnerRef = useRef < { preparing : boolean } | null > ( null ) ;
812- // Replacing the draft/edit or leaving the screen invalidates pending preparation.
813- useLayoutEffect ( ( ) => {
814- submissionOwnerRef . current = isScreenFocused ? { preparing : false } : null ;
815- return ( ) => {
816- submissionOwnerRef . current = null ;
817- } ;
818- } , [
819- flow . draftKey ,
820- selectedProject ?. environmentId ,
821- selectedProject ?. id ,
822- flow . editingPendingTask ,
823- isScreenFocused ,
824- ] ) ;
825-
826808 async function handleStart ( ) : Promise < import ( "@t3tools/contracts" ) . MessageId | null > {
827- if ( isComposerInteractionLocked ) return null ;
828- const owner = submissionOwnerRef . current ;
829- const draftKey = flow . draftKey ;
830- if ( ! owner || owner . preparing || ! draftKey || ! navigation . isFocused ( ) ) return null ;
831- owner . preparing = true ;
832- const started = await settlePromise ( ( ) =>
833- submitComposer (
834- draftKey ,
835- promptInputRef . current ,
836- // Preparation can publish corrected text before React replaces the flow callbacks.
837- ( ) => startPreparedDraftRef . current ( ) ,
838- ( ) => submissionOwnerRef . current === owner && navigation . isFocused ( ) ,
839- ) ,
840- ) ;
841- owner . preparing = false ;
842- if ( AsyncResult . isFailure ( started ) ) {
843- const error = squashAtomCommandFailure ( started ) ;
844- Dialog . alert (
845- "Could not queue task" ,
846- error instanceof Error ? error . message : "The task could not be saved to the outbox." ,
847- ) ;
848- }
849- return AsyncResult . isSuccess ( started ) ? started . value : null ;
850- }
851-
852- async function startPreparedDraft ( ) : Promise < import ( "@t3tools/contracts" ) . MessageId | null > {
853809 const selectedProject = flow . selectedProject ;
854810 const draftKey = flow . draftKey ;
855811 if (
0 commit comments