1- import { type FC , useEffect , useState , useRef } from 'react' ;
1+ import { type FC , useEffect , useState } from 'react' ;
22import { Layout } from '@oasisprotocol/ui-library/src/components/ui/layout' ;
33import { Header } from '../../components/Layout/Header' ;
44import { Footer } from '../../components/Layout/Footer' ;
55import Bootstrap from './images/bootstrap.png' ;
66import type { AppData , MetadataFormData } from './types' ;
77import { stringify } from 'yaml' ;
8- import { useBuildRofl } from '../../backend/api' ;
8+ import { useBuildRofl , useGetRoflBuildResults } from '../../backend/api' ;
99import { useRoflAppBackendAuthContext } from '../../contexts/RoflAppBackendAuth/hooks' ;
1010
1111// TEMP
@@ -64,9 +64,12 @@ export const BootstrapStep: FC<BootstrapStepProps> = ({
6464} ) => {
6565 const [ currentIndex , setCurrentIndex ] = useState ( 0 ) ;
6666 const [ isVisible , setIsVisible ] = useState ( true ) ;
67- const hasTriggeredBuildRef = useRef ( false ) ;
67+ const [ taskId , setTaskId ] = useState < string | null > ( null ) ;
68+ const [ buildTriggered , setBuildTriggered ] = useState ( false ) ;
6869 const { token } = useRoflAppBackendAuthContext ( ) ;
69- const buildRoflMutation = useBuildRofl ( token ) ;
70+ const buildRoflMutation = useBuildRofl ( token , ( data ) =>
71+ setTaskId ( data . task_id )
72+ ) ;
7073
7174 if ( ! appData || ! template ) {
7275 throw new Error ( 'Missing data to bootstrap the app' ) ;
@@ -80,21 +83,16 @@ export const BootstrapStep: FC<BootstrapStepProps> = ({
8083 const manifest = Array . from ( new Uint8Array ( manifestBuf ) ) ;
8184 const compose = Array . from ( new Uint8Array ( composeBuf ) ) ;
8285
83- useEffect ( ( ) => {
84- // Revisit the logic to trigger the build only once
85- if (
86- ! hasTriggeredBuildRef . current &&
87- token &&
88- ! buildRoflMutation . isPending &&
89- ! buildRoflMutation . isSuccess
90- ) {
91- hasTriggeredBuildRef . current = true ;
92- buildRoflMutation . mutate ( {
93- manifest,
94- compose,
95- } ) ;
96- }
97- } , [ token , buildRoflMutation , manifest , compose ] ) ;
86+ if ( ! buildTriggered && token && appData && template ) {
87+ setBuildTriggered ( true ) ;
88+ buildRoflMutation . mutate ( {
89+ manifest,
90+ compose,
91+ } ) ;
92+ }
93+
94+ const { data } = useGetRoflBuildResults ( taskId , token ) ;
95+ console . log ( 'Build results:' , data ) ;
9896
9997 useEffect ( ( ) => {
10098 const interval = setInterval ( ( ) => {
0 commit comments