Skip to content

Commit b117ef7

Browse files
committed
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.
1 parent eedfd5e commit b117ef7

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/controllers/run-controller.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ export class RunController extends EventEmitter implements IRunController {
3838
const projectData = this.$projectDataService.getProjectData(projectDir);
3939
await this.initializeSetup(projectData);
4040

41-
const platforms = this.$devicesService.getPlatformsFromDeviceDescriptors(deviceDescriptors);
4241
const deviceDescriptorsForInitialSync = this.getDeviceDescriptorsForInitialSync(projectDir, deviceDescriptors);
42+
const newPlatforms = this.$devicesService.getPlatformsFromDeviceDescriptors(deviceDescriptors);
43+
const oldPlatforms = this.$liveSyncProcessDataService.getPlatforms(projectDir);
44+
const platforms = _.uniq(_.concat(newPlatforms, oldPlatforms));
4345

4446
this.$liveSyncProcessDataService.persistData(projectDir, deviceDescriptors, platforms);
4547

lib/definitions/livesync.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -492,5 +492,6 @@ declare global {
492492
getAllPersistedData(): IDictionary<ILiveSyncProcessData>;
493493
persistData(projectDir: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], platforms: string[]): void;
494494
hasDeviceDescriptors(projectDir: string): boolean;
495+
getPlatforms(projectDir: string): string[];
495496
}
496497
}

lib/services/livesync-process-data-service.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService {
66
this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve();
77
this.processes[projectDir].currentSyncAction = this.processes[projectDir].actionsChain;
88
this.processes[projectDir].isStopped = false;
9-
this.processes[projectDir].platforms = platforms;
9+
this.processes[projectDir].platforms = platforms;
1010

1111
const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir);
1212
this.processes[projectDir].deviceDescriptors = _.uniqBy(currentDeviceDescriptors.concat(deviceDescriptors), "identifier");
@@ -30,5 +30,11 @@ export class LiveSyncProcessDataService implements ILiveSyncProcessDataService {
3030
public getAllPersistedData() {
3131
return this.processes;
3232
}
33+
34+
public getPlatforms(projectDir: string): string[] {
35+
const liveSyncProcessesInfo = this.processes[projectDir] || <ILiveSyncProcessData>{};
36+
const currentPlatforms = liveSyncProcessesInfo.platforms;
37+
return currentPlatforms || [];
38+
}
3339
}
3440
$injector.register("liveSyncProcessDataService", LiveSyncProcessDataService);

0 commit comments

Comments
 (0)