mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-02 06:13:11 +08:00
fix: lastChecking
This commit is contained in:
13
lib/main.ts
13
lib/main.ts
@@ -131,14 +131,15 @@ function assertRelease() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastChecking = Date.now();
|
let lastChecking;
|
||||||
let lastResult: CheckResult = {};
|
const empty = {};
|
||||||
|
let lastResult: CheckResult;
|
||||||
export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
||||||
assertRelease();
|
assertRelease();
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (lastResult && now - lastChecking < 1000 * 60) {
|
if (lastResult && lastChecking && now - lastChecking < 1000 * 60) {
|
||||||
// logger('repeated checking, ignored');
|
// logger('repeated checking, ignored');
|
||||||
return lastResult;
|
return lastResult || empty;
|
||||||
}
|
}
|
||||||
lastChecking = now;
|
lastChecking = now;
|
||||||
if (blockUpdate && blockUpdate.until > Date.now() / 1000) {
|
if (blockUpdate && blockUpdate.until > Date.now() / 1000) {
|
||||||
@@ -148,7 +149,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|||||||
blockUpdate.until * 1000,
|
blockUpdate.until * 1000,
|
||||||
).toLocaleString()}"之后重试。`,
|
).toLocaleString()}"之后重试。`,
|
||||||
});
|
});
|
||||||
return lastResult;
|
return lastResult || empty;
|
||||||
}
|
}
|
||||||
report({ type: 'checking' });
|
report({ type: 'checking' });
|
||||||
let resp;
|
let resp;
|
||||||
@@ -172,7 +173,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
message: '无法连接更新服务器,请检查网络连接后重试',
|
message: '无法连接更新服务器,请检查网络连接后重试',
|
||||||
});
|
});
|
||||||
return lastResult;
|
return lastResult || empty;
|
||||||
}
|
}
|
||||||
await tryBackupEndpoints();
|
await tryBackupEndpoints();
|
||||||
return checkUpdate(APPKEY, true);
|
return checkUpdate(APPKEY, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user