Skip to content

Commit 5df6ec1

Browse files
author
Tsvetan Raikov
committed
Improved: The live sync successfull message appears twice in the code
1 parent 3295421 commit 5df6ec1

5 files changed

+19
-10
lines changed

lib/commands/debug.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
return (() => {
2222
let projectData: IProjectData = this.$injector.resolve("projectData");
2323

24-
this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${deviceAppData.device.deviceInfo.identifier}.`);
25-
2624
this.debugService.debugStop().wait();
2725

2826
let applicationId = deviceAppData.appIdentifier;

lib/services/livesync/android-platform-livesync-service.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
4141
}
4242

4343
if (postAction) {
44+
this.finishLivesync(deviceAppData).wait();
4445
return postAction(deviceAppData, localToDevicePaths).wait();
4546
}
4647

47-
return afterSyncAction().wait();
48+
afterSyncAction().wait();
49+
this.finishLivesync(deviceAppData).wait();
4850
}).future<void>()();
4951
};
5052
this.$devicesService.execute(action, canExecute).wait();

lib/services/livesync/ios-platform-livesync-service.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ class IOSPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
3737
}
3838

3939
if (postAction) {
40+
this.finishLivesync(deviceAppData).wait();
4041
return postAction(deviceAppData, localToDevicePaths).wait();
4142
}
4243

43-
return afterSyncAction().wait();
44+
afterSyncAction().wait();
45+
this.finishLivesync(deviceAppData).wait();
4446
}).future<void>()();
4547
};
4648
this.$devicesService.execute(action, canExecute).wait();

lib/services/livesync/livesync-service.ts

-5
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ class LiveSyncService implements ILiveSyncService {
110110
let watchForChangeActions: ((event: string, filePath: string, dispatcher: IFutureDispatcher) => void)[] = [];
111111
_.each(liveSyncData, (dataItem) => {
112112
let service = this.resolvePlatformLiveSyncBaseService(dataItem.platform, dataItem);
113-
114113
watchForChangeActions.push((event: string, filePath: string, dispatcher: IFutureDispatcher) => {
115-
if (!applicationReloadAction) {
116-
applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => service.refreshApplication(deviceAppData, localToDevicePaths);
117-
}
118-
119114
service.partialSync(event, filePath, dispatcher, applicationReloadAction);
120115
});
121116
service.fullSync(applicationReloadAction).wait();

lib/services/livesync/platform-livesync-service-base.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
9696
let deviceLiveSyncService = this.resolveDeviceSpecificLiveSyncService(deviceAppData.device.deviceInfo.platform, deviceAppData.device);
9797
this.$logger.info("Applying changes...");
9898
deviceLiveSyncService.refreshApplication(deviceAppData, localToDevicePaths, this.liveSyncData.forceExecuteFullSync).wait();
99+
}).future<void>()();
100+
}
101+
102+
protected finishLivesync(deviceAppData: Mobile.IDeviceAppData): IFuture<void> {
103+
return (() => {
104+
// This message is important because it signals Visual Studio Code that livesync has finished and debugger can be attached.
99105
this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${deviceAppData.device.deviceInfo.identifier}.`);
100106
}).future<void>()();
101107
}
@@ -187,7 +193,13 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
187193
let localToDevicePaths = this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, this.liveSyncData.projectFilesPath, filesToSync, this.liveSyncData.excludedProjectDirsAndFiles);
188194

189195
fileSyncAction(deviceAppData, localToDevicePaths).wait();
190-
afterFileSyncAction(deviceAppData, localToDevicePaths).wait();
196+
if (!afterFileSyncAction) {
197+
this.refreshApplication(deviceAppData, localToDevicePaths).wait();
198+
}
199+
this.finishLivesync(deviceAppData).wait();
200+
if (afterFileSyncAction) {
201+
afterFileSyncAction(deviceAppData, localToDevicePaths).wait();
202+
}
191203
}).future<void>()();
192204
};
193205

0 commit comments

Comments
 (0)