react-native-update 9.0.1 → 9.0.3

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 CHANGED
@@ -132,12 +132,13 @@ function assertRelease() {
132
132
  }
133
133
 
134
134
  let lastChecking = Date.now();
135
+ let lastResult: CheckResult = {};
135
136
  export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
136
137
  assertRelease();
137
138
  const now = Date.now();
138
- if (now - lastChecking < 1000 * 5) {
139
- logger('repeated checking, ignored');
140
- return;
139
+ if (lastResult && now - lastChecking < 1000 * 60) {
140
+ // logger('repeated checking, ignored');
141
+ return lastResult;
141
142
  }
142
143
  lastChecking = now;
143
144
  if (blockUpdate && blockUpdate.until > Date.now() / 1000) {
@@ -147,7 +148,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
147
148
  blockUpdate.until * 1000,
148
149
  ).toLocaleString()}"之后重试。`,
149
150
  });
150
- return;
151
+ return lastResult;
151
152
  }
152
153
  report({ type: 'checking' });
153
154
  let resp;
@@ -171,12 +172,14 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
171
172
  type: 'errorChecking',
172
173
  message: '无法连接更新服务器,请检查网络连接后重试',
173
174
  });
174
- return;
175
+ return lastResult;
175
176
  }
176
177
  await tryBackupEndpoints();
177
178
  return checkUpdate(APPKEY, true);
178
179
  }
179
180
  const result: CheckResult = await resp.json();
181
+
182
+ lastResult = result;
180
183
  // @ts-ignore
181
184
  checkOperation(result.op);
182
185
 
@@ -186,7 +189,7 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
186
189
  //@ts-ignore
187
190
  message: result.message,
188
191
  });
189
- return;
192
+ return lastResult;
190
193
  }
191
194
 
192
195
  return result;
package/lib/type.ts CHANGED
@@ -26,7 +26,8 @@ export interface UpdateAvailableResult {
26
26
  export type CheckResult =
27
27
  | ExpiredResult
28
28
  | UpTodateResult
29
- | UpdateAvailableResult;
29
+ | UpdateAvailableResult
30
+ | {};
30
31
 
31
32
  export interface ProgressData {
32
33
  hash: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {