@@ -1041,58 +1041,57 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
10411041 submittingRef . current = true ;
10421042 setError ( null ) ;
10431043 setIsSubmitting ( true ) ;
1044- return await ( async ( ) => {
1045- const result = await createNew ( {
1044+ const result = await createNew ( {
1045+ environmentId : environment . environmentId ,
1046+ input : { name : trimmedName } ,
1047+ } ) ;
1048+ if ( AsyncResult . isFailure ( result ) ) {
1049+ submittingRef . current = false ;
1050+ setIsSubmitting ( false ) ;
1051+ setError ( errorMessage ( Cause . squash ( result . cause ) ) ) ;
1052+ return ;
1053+ }
1054+ const { projectId, workspaceRoot, commitError } = result . value ;
1055+ if ( commitError !== undefined ) {
1056+ Dialog . alert ( "Created without a first commit" , commitError ) ;
1057+ }
1058+ if ( publishes && publishTarget !== null ) {
1059+ void publishRepository ( {
10461060 environmentId : environment . environmentId ,
1047- input : { name : trimmedName } ,
1061+ input : {
1062+ cwd : workspaceRoot ,
1063+ provider : publishTarget . definition . kind ,
1064+ repository : getNewProjectRepository ( publishTarget , workspaceRoot ) ,
1065+ visibility : "private" ,
1066+ } ,
1067+ } ) . then ( ( publishResult ) => {
1068+ if ( AsyncResult . isFailure ( publishResult ) ) {
1069+ Dialog . alert (
1070+ `Could not create the ${ publishTarget . definition . label } repository` ,
1071+ errorMessage ( Cause . squash ( publishResult . cause ) ) ,
1072+ ) ;
1073+ }
10481074 } ) ;
1049- if ( AsyncResult . isFailure ( result ) ) {
1050- setError ( errorMessage ( Cause . squash ( result . cause ) ) ) ;
1051- return ;
1052- }
1053- const { projectId, workspaceRoot, commitError } = result . value ;
1054- if ( commitError !== undefined ) {
1055- Dialog . alert ( "Created without a first commit" , commitError ) ;
1056- }
1057- if ( publishes && publishTarget !== null ) {
1058- void publishRepository ( {
1059- environmentId : environment . environmentId ,
1060- input : {
1061- cwd : workspaceRoot ,
1062- provider : publishTarget . definition . kind ,
1063- repository : getNewProjectRepository ( publishTarget , workspaceRoot ) ,
1064- visibility : "private" ,
1065- } ,
1066- } ) . then ( ( publishResult ) => {
1067- if ( AsyncResult . isFailure ( publishResult ) ) {
1068- Dialog . alert (
1069- `Could not create the ${ publishTarget . definition . label } repository` ,
1070- errorMessage ( Cause . squash ( publishResult . cause ) ) ,
1071- ) ;
1072- }
1073- } ) ;
1074- }
1075- // The draft screen resolves its project from the client store, so it
1076- // must not open before the create event has arrived.
1077- const project = await waitForProject (
1078- { environmentId : environment . environmentId , projectId } ,
1079- 15_000 ,
1075+ }
1076+ // The draft screen resolves its project from the client store, so it
1077+ // must not open before the create event has arrived.
1078+ const project = await waitForProject (
1079+ { environmentId : environment . environmentId , projectId } ,
1080+ 15_000 ,
1081+ ) ;
1082+ submittingRef . current = false ;
1083+ setIsSubmitting ( false ) ;
1084+ if ( project === null ) {
1085+ setName ( "" ) ;
1086+ setError (
1087+ "The project was created but has not reached this device yet. It will appear in the project list once the connection catches up." ,
10801088 ) ;
1081- if ( project === null ) {
1082- setName ( "" ) ;
1083- setError (
1084- "The project was created but has not reached this device yet. It will appear in the project list once the connection catches up." ,
1085- ) ;
1086- return ;
1087- }
1088- openNewTaskDraft ( navigation , {
1089- environmentId : environment . environmentId ,
1090- projectId,
1091- title : trimmedName ,
1092- } ) ;
1093- } ) ( ) . finally ( ( ) => {
1094- submittingRef . current = false ;
1095- setIsSubmitting ( false ) ;
1089+ return ;
1090+ }
1091+ openNewTaskDraft ( navigation , {
1092+ environmentId : environment . environmentId ,
1093+ projectId,
1094+ title : trimmedName ,
10961095 } ) ;
10971096 } ;
10981097
0 commit comments