@@ -321,15 +321,19 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
321
321
// In case liveSync is called for a second time for the same projectDir.
322
322
const isAlreadyLiveSyncing = this . liveSyncProcessesInfo [ projectData . projectDir ] && ! this . liveSyncProcessesInfo [ projectData . projectDir ] . isStopped ;
323
323
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
+
324
328
this . setLiveSyncProcessInfo ( liveSyncData . projectDir , deviceDescriptors ) ;
325
329
326
330
if ( ! liveSyncData . skipWatcher && this . liveSyncProcessesInfo [ projectData . projectDir ] . deviceDescriptors . length ) {
327
331
// Should be set after prepare
328
332
this . $usbLiveSyncService . isInitialized = true ;
329
- await this . startWatcher ( projectData , liveSyncData , deviceDescriptors , { isAlreadyLiveSyncing } ) ;
333
+ await this . startWatcher ( projectData , liveSyncData , deviceDescriptors ) ;
330
334
}
331
335
332
- await this . initialSync ( projectData , liveSyncData , deviceDescriptors , { isAlreadyLiveSyncing } ) ;
336
+ await this . initialSync ( projectData , liveSyncData , deviceDescriptorsForInitialSync ) ;
333
337
}
334
338
335
339
private setLiveSyncProcessInfo ( projectDir : string , deviceDescriptors : ILiveSyncDeviceInfo [ ] ) : void {
@@ -342,13 +346,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
342
346
this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors = _ . uniqBy ( currentDeviceDescriptors . concat ( deviceDescriptors ) , deviceDescriptorPrimaryKey ) ;
343
347
}
344
348
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
-
352
349
private getLiveSyncService ( platform : string ) : IPlatformLiveSyncService {
353
350
if ( this . $mobileHelper . isiOSPlatform ( platform ) ) {
354
351
return this . $injector . resolve ( "iOSLiveSyncService" ) ;
@@ -450,7 +447,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
450
447
return null ;
451
448
}
452
449
453
- private async initialSyncCore ( projectData : IProjectData , deviceDescriptors : ILiveSyncDeviceInfo [ ] , liveSyncData : ILiveSyncInfo ) : Promise < void > {
450
+ private async initialSync ( projectData : IProjectData , liveSyncData : ILiveSyncInfo , deviceDescriptors : ILiveSyncDeviceInfo [ ] ) : Promise < void > {
454
451
const preparedPlatforms : string [ ] = [ ] ;
455
452
const rebuiltInformation : ILiveSyncBuildInfo [ ] = [ ] ;
456
453
@@ -524,7 +521,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
524
521
} ;
525
522
}
526
523
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 > {
528
525
const devicesIds = deviceDescriptors . map ( dd => dd . identifier ) ;
529
526
const devices = _ . filter ( this . $devicesService . getDeviceInstances ( ) , device => _ . includes ( devicesIds , device . deviceInfo . identifier ) ) ;
530
527
const platforms = _ ( devices ) . map ( device => device . deviceInfo . platform ) . uniq ( ) . value ( ) ;
0 commit comments