Skip to content

Commit 57cb647

Browse files
committed
Generate QR code from command not inside preview-app-livesync-service.js
1 parent 226060d commit 57cb647

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

lib/commands/preview.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export class PreviewCommand implements ICommand {
44
constructor(private $liveSyncService: ILiveSyncService,
55
private $projectData: IProjectData,
66
private $options: IOptions,
7+
private $playgroundQrCodeGenerator: IPlaygroundQrCodeGenerator,
78
private $previewCommandHelper: IPreviewCommandHelper) { }
89

910
public async execute(args: string[]): Promise<void> {
@@ -20,6 +21,8 @@ export class PreviewCommand implements ICommand {
2021
env: this.$options.env,
2122
timeout: this.$options.timeout
2223
});
24+
25+
await this.$playgroundQrCodeGenerator.generateQrCodeForCurrentApp();
2326
}
2427

2528
public async canExecute(args: string[]): Promise<boolean> {

lib/definitions/preview-app-livesync.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FilePayload, Device } from "nativescript-preview-sdk";
22

33
declare global {
44
interface IPreviewAppLiveSyncService {
5+
initialize(): void;
56
initialSync(data: IPreviewAppLiveSyncData): Promise<void>;
67
syncFiles(data: IPreviewAppLiveSyncData, filesToSync: string[]): Promise<void>;
78
stopLiveSync(): Promise<void>;

lib/helpers/preview-command-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class PreviewCommandHelper implements IPreviewCommandHelper {
1212
});
1313
}
1414

15-
public run() {
15+
public run(): void {
1616
this.startWaitingForCommand();
1717
}
1818

lib/services/livesync/livesync-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
320320
private async liveSyncOperation(deviceDescriptors: ILiveSyncDeviceInfo[], liveSyncData: ILiveSyncInfo, projectData: IProjectData): Promise<void> {
321321
let deviceDescriptorsForInitialSync: ILiveSyncDeviceInfo[] = [];
322322

323-
if (!liveSyncData.syncToPreviewApp) {
323+
if (liveSyncData.syncToPreviewApp) {
324+
this.$previewAppLiveSyncService.initialize();
325+
} else {
324326
await this.$pluginsService.ensureAllDependenciesAreInstalled(projectData);
325327
// In case liveSync is called for a second time for the same projectDir.
326328
const isAlreadyLiveSyncing = this.liveSyncProcessesInfo[projectData.projectDir] && !this.liveSyncProcessesInfo[projectData.projectDir].isStopped;

lib/services/livesync/playground/preview-app-livesync-service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
1515
private $projectDataService: IProjectDataService,
1616
private $previewSdkService: IPreviewSdkService,
1717
private $previewAppPluginsService: IPreviewAppPluginsService,
18-
private $projectFilesManager: IProjectFilesManager,
19-
private $playgroundQrCodeGenerator: IPlaygroundQrCodeGenerator) { }
18+
private $projectFilesManager: IProjectFilesManager) { }
2019

21-
public async initialSync(data: IPreviewAppLiveSyncData): Promise<void> {
20+
public initialize() {
2221
this.$previewSdkService.initialize();
22+
}
23+
24+
public async initialSync(data: IPreviewAppLiveSyncData): Promise<void> {
2325
this.$previewSdkService.on(PreviewSdkEventNames.DEVICE_CONNECTED, async (device: Device) => {
2426
this.$logger.trace("Found connected device", device);
2527
await this.syncFilesOnDeviceSafe(data, device);
2628
});
27-
await this.$playgroundQrCodeGenerator.generateQrCodeForCurrentApp();
2829
}
2930

3031
public async syncFiles(data: IPreviewAppLiveSyncData, files: string[]): Promise<void> {

0 commit comments

Comments
 (0)