Skip to content

Commit 6a565cf

Browse files
committed
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.
1 parent e5f9d45 commit 6a565cf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/controllers/preview-app-controller.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Device, FilesPayload } from "nativescript-preview-sdk";
22
import { TrackActionNames, PREPARE_READY_EVENT_NAME } from "../constants";
33
import { PrepareController } from "./prepare-controller";
44
import { performanceLog } from "../common/decorators";
5-
import { stringify, hook } from "../common/helpers";
5+
import { stringify } from "../common/helpers";
66
import { HmrConstants } from "../common/constants";
77
import { EventEmitter } from "events";
88
import { PrepareDataService } from "../services/prepare-data-service";
@@ -27,7 +27,6 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
2727
private $prepareDataService: PrepareDataService
2828
) { super(); }
2929

30-
@hook("preview-sync")
3130
public async startPreview(data: IPreviewAppLiveSyncData): Promise<IQrCodeImageData> {
3231
await this.previewCore(data);
3332

@@ -61,6 +60,8 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
6160
});
6261
}
6362

63+
await this.$hooksService.executeBeforeHooks("preview-sync", { ...data, platform: device.platform });
64+
6465
if (data.useHotModuleReload) {
6566
this.$hmrStatusService.attachToHmrStatusEvent();
6667
}

0 commit comments

Comments
 (0)