@@ -121,43 +121,37 @@ function OdometerReceiptStitcher({
121121 { uri : endUri , image : odometerEndImage } ,
122122 ] . filter ( ( item ) : item is { uri : string ; image : typeof odometerStartImage } => ! ! item . uri && item . uri . startsWith ( 'blob:' ) ) ;
123123
124- const cleanup = ( ) => {
124+ let hasExpiredImages = false ;
125+ Promise . all (
126+ localImages . map ( ( { uri, image} ) =>
127+ checkIfLocalFileIsAccessible (
128+ getOdometerImageName ( image ) ,
129+ uri ,
130+ typeof image === 'object' ? image ?. type : undefined ,
131+ ( ) => { } ,
132+ ( ) => {
133+ hasExpiredImages = true ;
134+ } ,
135+ ) ,
136+ ) ,
137+ ) . then ( ( ) => {
138+ if ( ignore ) {
139+ return ;
140+ }
141+ if ( hasExpiredImages ) {
142+ onStitchingChange ( false ) ;
143+ clearOdometerDraftTransactionState ( transaction ) ;
144+ navigateToStartMoneyRequestStep ( CONST . IOU . REQUEST_TYPE . DISTANCE_ODOMETER , iouType , transaction . transactionID , reportID , CONST . IOU . ACTION . CREATE , backToReport ) ;
145+ return ;
146+ }
147+ runStitch ( ) ;
148+ } ) ;
149+
150+ return ( ) => {
125151 ignore = true ;
126152 onStitchingChange ( false ) ;
127153 cancelSpan ( CONST . TELEMETRY . SPAN_ODOMETER_IMAGE_STITCH ) ;
128154 } ;
129-
130- if ( localImages . length > 0 ) {
131- let hasExpiredImages = false ;
132- Promise . all (
133- localImages . map ( ( { uri, image} ) =>
134- checkIfLocalFileIsAccessible (
135- getOdometerImageName ( image ) ,
136- uri ,
137- typeof image === 'object' ? image ?. type : undefined ,
138- ( ) => { } ,
139- ( ) => {
140- hasExpiredImages = true ;
141- } ,
142- ) ,
143- ) ,
144- ) . then ( ( ) => {
145- if ( ignore ) {
146- return ;
147- }
148- if ( hasExpiredImages ) {
149- onStitchingChange ( false ) ;
150- clearOdometerDraftTransactionState ( transaction ) ;
151- navigateToStartMoneyRequestStep ( CONST . IOU . REQUEST_TYPE . DISTANCE_ODOMETER , iouType , transaction . transactionID , reportID , CONST . IOU . ACTION . CREATE , backToReport ) ;
152- return ;
153- }
154- runStitch ( ) ;
155- } ) ;
156- return cleanup ;
157- }
158- runStitch ( ) ;
159-
160- return cleanup ;
161155 } , [ isOdometerDistanceRequest , isFocused , odometerStartImage , odometerEndImage , transaction , reportID , backToReport , translate , iouType , onStitchingChange , onStitchError ] ) ;
162156
163157 return null ;
0 commit comments