@@ -321,15 +321,19 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
321321 // In case liveSync is called for a second time for the same projectDir.
322322 const isAlreadyLiveSyncing = this . liveSyncProcessesInfo [ projectData . projectDir ] && ! this . liveSyncProcessesInfo [ projectData . projectDir ] . isStopped ;
323323
324+ // Prevent cases where liveSync is called consecutive times with the same device, for example [ A, B, C ] and then [ A, B, D ] - we want to execute initialSync only for D.
325+ const currentlyRunningDeviceDescriptors = this . getLiveSyncDeviceDescriptors ( projectData . projectDir ) ;
326+ const deviceDescriptorsForInitialSync = isAlreadyLiveSyncing ? _ . differenceBy ( deviceDescriptors , currentlyRunningDeviceDescriptors , deviceDescriptorPrimaryKey ) : deviceDescriptors ;
327+
324328 this . setLiveSyncProcessInfo ( liveSyncData . projectDir , deviceDescriptors ) ;
325329
326330 if ( ! liveSyncData . skipWatcher && this . liveSyncProcessesInfo [ projectData . projectDir ] . deviceDescriptors . length ) {
327331 // Should be set after prepare
328332 this . $usbLiveSyncService . isInitialized = true ;
329- await this . startWatcher ( projectData , liveSyncData , deviceDescriptors , { isAlreadyLiveSyncing } ) ;
333+ await this . startWatcher ( projectData , liveSyncData , deviceDescriptors ) ;
330334 }
331335
332- await this . initialSync ( projectData , liveSyncData , deviceDescriptors , { isAlreadyLiveSyncing } ) ;
336+ await this . initialSync ( projectData , liveSyncData , deviceDescriptorsForInitialSync ) ;
333337 }
334338
335339 private setLiveSyncProcessInfo ( projectDir : string , deviceDescriptors : ILiveSyncDeviceInfo [ ] ) : void {
@@ -342,13 +346,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
342346 this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors = _ . uniqBy ( currentDeviceDescriptors . concat ( deviceDescriptors ) , deviceDescriptorPrimaryKey ) ;
343347 }
344348
345- private async initialSync ( projectData : IProjectData , liveSyncData : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceInfo [ ] , options : { isAlreadyLiveSyncing : boolean } ) : Promise < void > {
346- // Prevent cases where liveSync is called consecutive times with the same device, for example [ A, B, C ] and then [ A, B, D ] - we want to execute initialSync only for D.
347- const currentlyRunningDeviceDescriptors = this . getLiveSyncDeviceDescriptors ( projectData . projectDir ) ;
348- const deviceDescriptorsForInitialSync = options . isAlreadyLiveSyncing ? _ . differenceBy ( deviceDescriptors , currentlyRunningDeviceDescriptors , deviceDescriptorPrimaryKey ) : deviceDescriptors ;
349- await this . initialSyncCore ( projectData , deviceDescriptorsForInitialSync , liveSyncData ) ;
350- }
351-
352349 private getLiveSyncService ( platform : string ) : IPlatformLiveSyncService {
353350 if ( this . $mobileHelper . isiOSPlatform ( platform ) ) {
354351 return this . $injector . resolve ( "iOSLiveSyncService" ) ;
@@ -450,7 +447,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
450447 return null ;
451448 }
452449
453- private async initialSyncCore ( projectData : IProjectData , deviceDescriptors : ILiveSyncDeviceInfo [ ] , liveSyncData : ILiveSyncInfo ) : Promise < void > {
450+ private async initialSync ( projectData : IProjectData , liveSyncData : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceInfo [ ] ) : Promise < void > {
454451 const preparedPlatforms : string [ ] = [ ] ;
455452 const rebuiltInformation : ILiveSyncBuildInfo [ ] = [ ] ;
456453
@@ -524,7 +521,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
524521 } ;
525522 }
526523
527- private async startWatcher ( projectData : IProjectData , liveSyncData : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceInfo [ ] , options : { isAlreadyLiveSyncing : boolean } ) : Promise < void > {
524+ private async startWatcher ( projectData : IProjectData , liveSyncData : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceInfo [ ] ) : Promise < void > {
528525 const devicesIds = deviceDescriptors . map ( dd => dd . identifier ) ;
529526 const devices = _ . filter ( this . $devicesService . getDeviceInstances ( ) , device => _ . includes ( devicesIds , device . deviceInfo . identifier ) ) ;
530527 const platforms = _ ( devices ) . map ( device => device . deviceInfo . platform ) . uniq ( ) . value ( ) ;
0 commit comments