react-native-update 9.0.2 → 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 +10 -8
- package/lib/type.ts +2 -1
- 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
|
-
logger('repeated checking, ignored');
|
|
141
|
-
return lastResult;
|
|
140
|
+
if (lastResult && lastChecking && now - lastChecking < 1000 * 60) {
|
|
141
|
+
// logger('repeated checking, ignored');
|
|
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;
|
|
152
|
+
return lastResult || empty;
|
|
152
153
|
}
|
|
153
154
|
report({ type: 'checking' });
|
|
154
155
|
let resp;
|
|
@@ -172,12 +173,13 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|
|
172
173
|
type: 'errorChecking',
|
|
173
174
|
message: '无法连接更新服务器,请检查网络连接后重试',
|
|
174
175
|
});
|
|
175
|
-
return;
|
|
176
|
+
return lastResult || empty;
|
|
176
177
|
}
|
|
177
178
|
await tryBackupEndpoints();
|
|
178
179
|
return checkUpdate(APPKEY, true);
|
|
179
180
|
}
|
|
180
181
|
const result: CheckResult = await resp.json();
|
|
182
|
+
|
|
181
183
|
lastResult = result;
|
|
182
184
|
// @ts-ignore
|
|
183
185
|
checkOperation(result.op);
|
|
@@ -188,7 +190,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
|
|
|
188
190
|
//@ts-ignore
|
|
189
191
|
message: result.message,
|
|
190
192
|
});
|
|
191
|
-
return;
|
|
193
|
+
return lastResult;
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
return result;
|
package/lib/type.ts
CHANGED