From 08b50dd78768fb97a0aec51dae7000d1aa5ee594 Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Thu, 11 Aug 2016 18:56:54 +0300 Subject: [PATCH] Improved: The live sync successfull message appears twice in the code --- lib/commands/debug.ts | 2 -- .../livesync/android-platform-livesync-service.ts | 4 +++- .../livesync/ios-platform-livesync-service.ts | 4 +++- lib/services/livesync/livesync-service.ts | 5 ----- .../livesync/platform-livesync-service-base.ts | 14 +++++++++++++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index 50665aa2d2..f38ee4548f 100644 --- a/lib/commands/debug.ts +++ b/lib/commands/debug.ts @@ -21,8 +21,6 @@ return (() => { let projectData: IProjectData = this.$injector.resolve("projectData"); - this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${deviceAppData.device.deviceInfo.identifier}.`); - this.debugService.debugStop().wait(); let applicationId = deviceAppData.appIdentifier; diff --git a/lib/services/livesync/android-platform-livesync-service.ts b/lib/services/livesync/android-platform-livesync-service.ts index 3721fae5d8..342a2c2b2a 100644 --- a/lib/services/livesync/android-platform-livesync-service.ts +++ b/lib/services/livesync/android-platform-livesync-service.ts @@ -41,10 +41,12 @@ class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase { } if (postAction) { + this.finishLivesync(deviceAppData).wait(); return postAction(deviceAppData, localToDevicePaths).wait(); } - return afterSyncAction().wait(); + afterSyncAction().wait(); + this.finishLivesync(deviceAppData).wait(); }).future()(); }; this.$devicesService.execute(action, canExecute).wait(); diff --git a/lib/services/livesync/ios-platform-livesync-service.ts b/lib/services/livesync/ios-platform-livesync-service.ts index 5686d6976f..2e5d67321c 100644 --- a/lib/services/livesync/ios-platform-livesync-service.ts +++ b/lib/services/livesync/ios-platform-livesync-service.ts @@ -37,10 +37,12 @@ class IOSPlatformLiveSyncService extends PlatformLiveSyncServiceBase { } if (postAction) { + this.finishLivesync(deviceAppData).wait(); return postAction(deviceAppData, localToDevicePaths).wait(); } - return afterSyncAction().wait(); + afterSyncAction().wait(); + this.finishLivesync(deviceAppData).wait(); }).future()(); }; this.$devicesService.execute(action, canExecute).wait(); diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index 7128278262..e6c2454191 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -110,12 +110,7 @@ class LiveSyncService implements ILiveSyncService { let watchForChangeActions: ((event: string, filePath: string, dispatcher: IFutureDispatcher) => void)[] = []; _.each(liveSyncData, (dataItem) => { let service = this.resolvePlatformLiveSyncBaseService(dataItem.platform, dataItem); - watchForChangeActions.push((event: string, filePath: string, dispatcher: IFutureDispatcher) => { - if (!applicationReloadAction) { - applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => service.refreshApplication(deviceAppData, localToDevicePaths); - } - service.partialSync(event, filePath, dispatcher, applicationReloadAction); }); service.fullSync(applicationReloadAction).wait(); diff --git a/lib/services/livesync/platform-livesync-service-base.ts b/lib/services/livesync/platform-livesync-service-base.ts index 52fd478dd9..c52ea4f250 100644 --- a/lib/services/livesync/platform-livesync-service-base.ts +++ b/lib/services/livesync/platform-livesync-service-base.ts @@ -96,6 +96,12 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe let deviceLiveSyncService = this.resolveDeviceSpecificLiveSyncService(deviceAppData.device.deviceInfo.platform, deviceAppData.device); this.$logger.info("Applying changes..."); deviceLiveSyncService.refreshApplication(deviceAppData, localToDevicePaths, this.liveSyncData.forceExecuteFullSync).wait(); + }).future()(); + } + + protected finishLivesync(deviceAppData: Mobile.IDeviceAppData): IFuture { + return (() => { + // This message is important because it signals Visual Studio Code that livesync has finished and debugger can be attached. this.$logger.info(`Successfully synced application ${deviceAppData.appIdentifier} on device ${deviceAppData.device.deviceInfo.identifier}.`); }).future()(); } @@ -187,7 +193,13 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe let localToDevicePaths = this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, this.liveSyncData.projectFilesPath, filesToSync, this.liveSyncData.excludedProjectDirsAndFiles); fileSyncAction(deviceAppData, localToDevicePaths).wait(); - afterFileSyncAction(deviceAppData, localToDevicePaths).wait(); + if (!afterFileSyncAction) { + this.refreshApplication(deviceAppData, localToDevicePaths).wait(); + } + this.finishLivesync(deviceAppData).wait(); + if (afterFileSyncAction) { + afterFileSyncAction(deviceAppData, localToDevicePaths).wait(); + } }).future()(); };