@@ -57,17 +57,18 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
5757 const platformData = this . $platformsData . getPlatformData ( platform , projectData ) ;
5858 const currentHmrData = _ . cloneDeep ( hmrData ) ;
5959 const filesToSync = _ . cloneDeep ( filesToSyncMap [ platform ] ) ;
60- promise = this . applyChanges ( platformData , projectData , filesToSync , data . appFilesUpdaterOptions . useHotModuleReload ) ;
60+ promise = this . applyChanges ( platformData , projectData , filesToSync , { useHotModuleReload : data . appFilesUpdaterOptions . useHotModuleReload } ) ;
6161 await promise ;
6262
6363 if ( data . appFilesUpdaterOptions . useHotModuleReload && currentHmrData . hash ) {
6464 const devices = _ . filter ( this . $previewSdkService . connectedDevices , { platform : platform . toLowerCase ( ) } ) ;
65- _ . forEach ( devices , async ( previewDevice : Device ) => {
66- const status = await this . $hmrStatusService . awaitHmrStatus ( previewDevice . id , currentHmrData . hash ) ;
65+
66+ await Promise . all ( _ . map ( devices , async ( previewDevice : Device ) => {
67+ const status = await this . $hmrStatusService . getHmrStatus ( previewDevice . id , currentHmrData . hash ) ;
6768 if ( status === HmrConstants . HMR_ERROR_STATUS ) {
68- await this . applyChanges ( platformData , projectData , currentHmrData . fallbackFiles [ platform ] , false ) ;
69+ await this . applyChanges ( platformData , projectData , currentHmrData . fallbackFiles [ platform ] , { useHotModuleReload : false } , previewDevice . id ) ;
6970 }
70- } ) ;
71+ } ) ) ;
7172 }
7273 } ) ;
7374 filesToSyncMap [ platform ] = [ ] ;
@@ -124,7 +125,7 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
124125
125126 let result : FilesPayload = null ;
126127 if ( files && files . length ) {
127- result = await this . applyChanges ( platformData , projectData , files , data . appFilesUpdaterOptions . useHotModuleReload ) ;
128+ result = await this . applyChanges ( platformData , projectData , files , { useHotModuleReload : data . appFilesUpdaterOptions . useHotModuleReload } ) ;
128129 this . $logger . info ( `Successfully synced ${ result . files . map ( filePayload => filePayload . file . yellow ) } for platform ${ platform } .` ) ;
129130 } else {
130131 const hmrMode = data . appFilesUpdaterOptions . useHotModuleReload ? 1 : 0 ;
@@ -138,7 +139,7 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
138139 }
139140 }
140141
141- private async applyChanges ( platformData : IPlatformData , projectData : IProjectData , files : string [ ] , useHotModuleReload : Boolean , deviceId ?: string ) : Promise < FilesPayload > {
142+ private async applyChanges ( platformData : IPlatformData , projectData : IProjectData , files : string [ ] , { useHotModuleReload } : { useHotModuleReload : Boolean } , deviceId ?: string ) : Promise < FilesPayload > {
142143 const hmrMode = useHotModuleReload ? 1 : 0 ;
143144 const payloads = this . getFilesPayload ( platformData , projectData , hmrMode , _ ( files ) . uniq ( ) . value ( ) , deviceId ) ;
144145 await this . $previewSdkService . applyChanges ( payloads ) ;
0 commit comments