1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-30 04:43:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

support multiple versions

This commit is contained in:
sunnylqm
2025-09-04 00:24:35 +08:00
parent 41e1028b2d
commit e58903a634
3 changed files with 116 additions and 84 deletions

View File

@@ -91,7 +91,8 @@ export class Pushy {
options = defaultClientOptions;
clientType: 'Pushy' | 'Cresc' = 'Pushy';
lastChecking?: number;
lastRespJson?: Promise<any>;
lastRespJson?: Promise<CheckResult>;
lastRespText?: Promise<string>;
version = cInfo.rnu;
loggerPromise = (() => {
@@ -294,20 +295,23 @@ export class Pushy {
this.throwIfEnabled(new Error('errorChecking'));
return this.lastRespJson ? await this.lastRespJson : emptyObj;
}
if (resp.status !== 200) {
const errorMessage = `${resp.status}: ${resp.statusText}`;
this.report({
type: 'errorChecking',
message: errorMessage,
});
this.throwIfEnabled(new Error(errorMessage));
log('error checking response:', resp.status, await resp.text());
return this.lastRespJson ? await this.lastRespJson : emptyObj;
}
this.lastRespJson = resp.json();
const result: CheckResult = await this.lastRespJson;
log('checking result:', result);
if (resp.status !== 200) {
this.report({
type: 'errorChecking',
message: result.message,
});
this.throwIfEnabled(new Error(result.message));
}
return result;
};
getBackupEndpoints = async () => {