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 CHANGED
@@ -131,14 +131,15 @@ function assertRelease() {
131
131
  }
132
132
  }
133
133
 
134
- let lastChecking = Date.now();
135
- let lastResult:CheckResult;
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
@@ -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.2",
3
+ "version": "9.0.4",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {