1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm 2024-08-01 11:00:39 +08:00
parent 5e89fb4a25
commit d666e8c0f3
No known key found for this signature in database
3 changed files with 11 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.11.4", "version": "10.11.5",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {

View File

@ -172,7 +172,6 @@ export class Pushy {
return await this.lastRespJson; return await this.lastRespJson;
} }
this.lastChecking = now; this.lastChecking = now;
this.report({ type: 'checking' });
const fetchBody = { const fetchBody = {
packageVersion, packageVersion,
hash: currentVersion, hash: currentVersion,
@ -183,16 +182,21 @@ export class Pushy {
if (__DEV__) { if (__DEV__) {
delete fetchBody.buildTime; delete fetchBody.buildTime;
} }
const body = JSON.stringify(fetchBody);
const fetchPayload = { const fetchPayload = {
method: 'POST', method: 'POST',
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify(fetchBody), body,
}; };
let resp; let resp;
try { try {
this.report({
type: 'checking',
message: this.options.appKey + ': ' + body,
});
resp = await fetch(this.getCheckUrl(), fetchPayload); resp = await fetch(this.getCheckUrl(), fetchPayload);
} catch (e: any) { } catch (e: any) {
this.report({ this.report({
@ -221,6 +225,8 @@ export class Pushy {
const result: CheckResult = await this.lastRespJson; const result: CheckResult = await this.lastRespJson;
log('checking result:', result);
if (resp.status !== 200) { if (resp.status !== 200) {
this.report({ this.report({
type: 'errorChecking', type: 'errorChecking',

View File

@ -290,10 +290,9 @@ export const PushyProvider = ({
); );
const parseTestQrCode = useCallback( const parseTestQrCode = useCallback(
(code: string) => { (code: string | PushyTestPayload) => {
let payload: PushyTestPayload;
try { try {
payload = JSON.parse(code); const payload = typeof code === 'string' ? JSON.parse(code) : code;
return parseTestPayload(payload); return parseTestPayload(payload);
} catch { } catch {
return false; return false;