react-native-update 9.0.3 → 9.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/main.ts +7 -6
- package/package.json +1 -1
package/lib/main.ts
CHANGED
|
@@ -131,14 +131,15 @@ function assertRelease() {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
let lastChecking
|
|
135
|
-
|
|
134
|
+
let lastChecking;
|
|
135
|
+
const empty = {};
|
|
136
|
+
let lastResult: CheckResult;
|
|
136
137
|
export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|
137
138
|
assertRelease();
|
|
138
139
|
const now = Date.now();
|
|
139
|
-
if (lastResult && now - lastChecking < 1000 * 60) {
|
|
140
|
+
if (lastResult && lastChecking && now - lastChecking < 1000 * 60) {
|
|
140
141
|
// logger('repeated checking, ignored');
|
|
141
|
-
return lastResult;
|
|
142
|
+
return lastResult || empty;
|
|
142
143
|
}
|
|
143
144
|
lastChecking = now;
|
|
144
145
|
if (blockUpdate && blockUpdate.until > Date.now() / 1000) {
|
|
@@ -148,7 +149,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|
|
148
149
|
blockUpdate.until * 1000,
|
|
149
150
|
).toLocaleString()}"之后重试。`,
|
|
150
151
|
});
|
|
151
|
-
return lastResult;
|
|
152
|
+
return lastResult || empty;
|
|
152
153
|
}
|
|
153
154
|
report({ type: 'checking' });
|
|
154
155
|
let resp;
|
|
@@ -172,7 +173,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|
|
172
173
|
type: 'errorChecking',
|
|
173
174
|
message: '无法连接更新服务器,请检查网络连接后重试',
|
|
174
175
|
});
|
|
175
|
-
return lastResult;
|
|
176
|
+
return lastResult || empty;
|
|
176
177
|
}
|
|
177
178
|
await tryBackupEndpoints();
|
|
178
179
|
return checkUpdate(APPKEY, true);
|