From d666e8c0f387d79fb3f53af20054330f55946de6 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Thu, 1 Aug 2024 11:00:39 +0800 Subject: [PATCH] v10.11.5 --- package.json | 2 +- src/client.ts | 10 ++++++++-- src/provider.tsx | 5 ++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 19cc512..990a9e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.11.4", + "version": "10.11.5", "description": "react-native hot update", "main": "src/index", "scripts": { diff --git a/src/client.ts b/src/client.ts index 7e7ba31..9f25fd5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -172,7 +172,6 @@ export class Pushy { return await this.lastRespJson; } this.lastChecking = now; - this.report({ type: 'checking' }); const fetchBody = { packageVersion, hash: currentVersion, @@ -183,16 +182,21 @@ export class Pushy { if (__DEV__) { delete fetchBody.buildTime; } + const body = JSON.stringify(fetchBody); const fetchPayload = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, - body: JSON.stringify(fetchBody), + body, }; let resp; try { + this.report({ + type: 'checking', + message: this.options.appKey + ': ' + body, + }); resp = await fetch(this.getCheckUrl(), fetchPayload); } catch (e: any) { this.report({ @@ -221,6 +225,8 @@ export class Pushy { const result: CheckResult = await this.lastRespJson; + log('checking result:', result); + if (resp.status !== 200) { this.report({ type: 'errorChecking', diff --git a/src/provider.tsx b/src/provider.tsx index 0ce0722..f106aa7 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -290,10 +290,9 @@ export const PushyProvider = ({ ); const parseTestQrCode = useCallback( - (code: string) => { - let payload: PushyTestPayload; + (code: string | PushyTestPayload) => { try { - payload = JSON.parse(code); + const payload = typeof code === 'string' ? JSON.parse(code) : code; return parseTestPayload(payload); } catch { return false;