From b117ef72cb260f9464311de47b0992f0356c9bd9 Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 15 Jul 2019 09:05:10 +0300 Subject: [PATCH 1/2] fix: stop all webpack processes from sidekick when stopping the livesync Currently when livesync is started on iOS device from sidekick, {N} CLI persist that livesync is started for iOS platform. After that if the livesync process is started on android device, {N} CLI overrides the persisted platforms and stores that the livesync is started for Android platform. However, when the livesync is stopped, {N} CLI stops it only for android platform. This means that the iOS webpack process is alive and continues to report data. This led to the multiple livesync messages when syncing the changes. --- lib/controllers/run-controller.ts | 4 +++- lib/definitions/livesync.d.ts | 1 + lib/services/livesync-process-data-service.ts | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/controllers/run-controller.ts b/lib/controllers/run-controller.ts index bb46da92e5..259a44b99f 100644 --- a/lib/controllers/run-controller.ts +++ b/lib/controllers/run-controller.ts @@ -38,8 +38,10 @@ export class RunController extends EventEmitter implements IRunController { const projectData = this.$projectDataService.getProjectData(projectDir); await this.initializeSetup(projectData); - const platforms = this.$devicesService.getPlatformsFromDeviceDescriptors(deviceDescriptors); const deviceDescriptorsForInitialSync = this.getDeviceDescriptorsForInitialSync(projectDir, deviceDescriptors); + const newPlatforms = this.$devicesService.getPlatformsFromDeviceDescriptors(deviceDescriptors); + const oldPlatforms = this.$liveSyncProcessDataService.getPlatforms(projectDir); + const platforms = _.uniq(_.concat(newPlatforms, oldPlatforms)); this.$liveSyncProcessDataService.persistData(projectDir, deviceDescriptors, platforms); diff --git a/lib/definitions/livesync.d.ts b/lib/definitions/livesync.d.ts index b692609ccb..e4ac2c0d99 100644 --- a/lib/definitions/livesync.d.ts +++ b/lib/definitions/livesync.d.ts @@ -492,5 +492,6 @@ declare global { getAllPersistedData(): IDictionary; persistData(projectDir: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], platforms: string[]): void; hasDeviceDescriptors(projectDir: string): boolean; + getPlatforms(projectDir: string): string[]; } } diff --git a/lib/services/livesync-process-data-service.ts b/lib/services/livesync-process-data-service.ts index 6edd76ef88..487141aa04 100644 --- a/lib/services/livesync-process-data-service.ts +++ b/lib/services/livesync-process-data-service.ts @@ -6,7 +6,7 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService { this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve(); this.processes[projectDir].currentSyncAction = this.processes[projectDir].actionsChain; this.processes[projectDir].isStopped = false; - this.processes[projectDir].platforms = platforms; + this.processes[projectDir].platforms = platforms; const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir); this.processes[projectDir].deviceDescriptors = _.uniqBy(currentDeviceDescriptors.concat(deviceDescriptors), "identifier"); @@ -30,5 +30,11 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService { public getAllPersistedData() { return this.processes; } + + public getPlatforms(projectDir: string): string[] { + const liveSyncProcessesInfo = this.processes[projectDir] || {}; + const currentPlatforms = liveSyncProcessesInfo.platforms; + return currentPlatforms || []; + } } $injector.register("liveSyncProcessDataService", LiveSyncProcessDataService); From c575d50f6f49a0cbacb6eacaf96a680456373b38 Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 15 Jul 2019 14:09:44 +0300 Subject: [PATCH 2/2] chore: fix additional whitespace --- lib/services/livesync-process-data-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/livesync-process-data-service.ts b/lib/services/livesync-process-data-service.ts index 487141aa04..9975bdb6d2 100644 --- a/lib/services/livesync-process-data-service.ts +++ b/lib/services/livesync-process-data-service.ts @@ -6,7 +6,7 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService { this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve(); this.processes[projectDir].currentSyncAction = this.processes[projectDir].actionsChain; this.processes[projectDir].isStopped = false; - this.processes[projectDir].platforms = platforms; + this.processes[projectDir].platforms = platforms; const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir); this.processes[projectDir].deviceDescriptors = _.uniqBy(currentDeviceDescriptors.concat(deviceDescriptors), "identifier");