From 6a565cf1b4065fda88bee194b760fd0e7944e412 Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 18 Jun 2019 08:12:28 +0300 Subject: [PATCH] fix: fix the workflow of preview-sync hook The `kinvey-sdk` plugin relies on `preview-sync` hook and mainly on platform property from `hookArgs`. This PR changes the workflow of `preview-sync` hook and makes it the same as in NativeScript v5.4.0. In NativeScript v5.4.0 the hook is executed when pubnub reports the device that the QR code is scanned with. This way we're able to get the platform from device and adds it to the `hookArgs` passed to the hook. --- lib/controllers/preview-app-controller.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/controllers/preview-app-controller.ts b/lib/controllers/preview-app-controller.ts index f9af93ffa0..9cf26564d8 100644 --- a/lib/controllers/preview-app-controller.ts +++ b/lib/controllers/preview-app-controller.ts @@ -2,7 +2,7 @@ import { Device, FilesPayload } from "nativescript-preview-sdk"; import { TrackActionNames, PREPARE_READY_EVENT_NAME } from "../constants"; import { PrepareController } from "./prepare-controller"; import { performanceLog } from "../common/decorators"; -import { stringify, hook } from "../common/helpers"; +import { stringify } from "../common/helpers"; import { HmrConstants } from "../common/constants"; import { EventEmitter } from "events"; import { PrepareDataService } from "../services/prepare-data-service"; @@ -27,7 +27,6 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon private $prepareDataService: PrepareDataService ) { super(); } - @hook("preview-sync") public async startPreview(data: IPreviewAppLiveSyncData): Promise { await this.previewCore(data); @@ -61,6 +60,8 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon }); } + await this.$hooksService.executeBeforeHooks("preview-sync", { ...data, platform: device.platform }); + if (data.useHotModuleReload) { this.$hmrStatusService.attachToHmrStatusEvent(); }