react-native-update 9.1.2 → 9.1.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/index.web.js +1 -1
- package/lib/main.ts +4 -2
- package/lib/simpleUpdate.tsx +4 -4
- package/package.json +1 -1
package/lib/index.web.js
CHANGED
package/lib/main.ts
CHANGED
|
@@ -78,7 +78,7 @@ if (!uuid) {
|
|
|
78
78
|
const noop = () => {};
|
|
79
79
|
let reporter: UpdateEventsListener = noop;
|
|
80
80
|
|
|
81
|
-
export function
|
|
81
|
+
export function onPushyEvents(customReporter: UpdateEventsListener) {
|
|
82
82
|
reporter = customReporter;
|
|
83
83
|
if (isRolledBack) {
|
|
84
84
|
report({
|
|
@@ -322,10 +322,12 @@ function assertHash(hash: string) {
|
|
|
322
322
|
return true;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
let applyingUpdate = false;
|
|
325
326
|
export function switchVersion(hash: string) {
|
|
326
327
|
assertRelease();
|
|
327
|
-
if (assertHash(hash)) {
|
|
328
|
+
if (assertHash(hash) && !applyingUpdate) {
|
|
328
329
|
logger('switchVersion: ' + hash);
|
|
330
|
+
applyingUpdate = true;
|
|
329
331
|
PushyModule.reloadUpdate({ hash });
|
|
330
332
|
}
|
|
331
333
|
}
|
package/lib/simpleUpdate.tsx
CHANGED
|
@@ -16,20 +16,20 @@ import {
|
|
|
16
16
|
switchVersionLater,
|
|
17
17
|
markSuccess,
|
|
18
18
|
downloadAndInstallApk,
|
|
19
|
-
|
|
19
|
+
onPushyEvents,
|
|
20
20
|
} from './main';
|
|
21
21
|
import { UpdateEventsListener } from './type';
|
|
22
22
|
|
|
23
23
|
export function simpleUpdate(
|
|
24
24
|
WrappedComponent: ComponentType,
|
|
25
|
-
options: { appKey?: string;
|
|
25
|
+
options: { appKey?: string; onPushyEvents?: UpdateEventsListener } = {},
|
|
26
26
|
) {
|
|
27
|
-
const { appKey,
|
|
27
|
+
const { appKey, onPushyEvents: eventListeners } = options;
|
|
28
28
|
if (!appKey) {
|
|
29
29
|
throw new Error('appKey is required for simpleUpdate()');
|
|
30
30
|
}
|
|
31
31
|
if (typeof eventListeners === 'function') {
|
|
32
|
-
|
|
32
|
+
onPushyEvents(eventListeners);
|
|
33
33
|
}
|
|
34
34
|
return __DEV__
|
|
35
35
|
? WrappedComponent
|