react-native-update 10.36.5 → 10.37.0
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.
|
@@ -46,20 +46,9 @@ public class UpdateContext {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
SharedPreferences.Editor editor = this.sp.edit();
|
|
49
|
-
if (storedPackageVersion == null) {
|
|
50
|
-
editor.putString("packageVersion", packageVersion);
|
|
51
|
-
editor.apply();
|
|
52
|
-
storedPackageVersion = packageVersion;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (storedBuildTime == null) {
|
|
56
|
-
editor.putString("buildTime", buildTime);
|
|
57
|
-
editor.apply();
|
|
58
|
-
storedBuildTime = buildTime;
|
|
59
|
-
}
|
|
60
49
|
|
|
61
|
-
boolean packageVersionChanged = !packageVersion.equals(storedPackageVersion);
|
|
62
|
-
boolean buildTimeChanged = !buildTime.equals(storedBuildTime);
|
|
50
|
+
boolean packageVersionChanged = storedPackageVersion == null || !packageVersion.equals(storedPackageVersion);
|
|
51
|
+
boolean buildTimeChanged = storedBuildTime == null || !buildTime.equals(storedBuildTime);
|
|
63
52
|
|
|
64
53
|
if (packageVersionChanged || buildTimeChanged) {
|
|
65
54
|
// Execute cleanUp before clearing SharedPreferences to avoid race condition
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -65,6 +65,7 @@ const defaultClientOptions: ClientOptions = {
|
|
|
65
65
|
export const sharedState: {
|
|
66
66
|
progressHandlers: Record<string, EmitterSubscription>;
|
|
67
67
|
downloadedHash?: string;
|
|
68
|
+
toHash?: string;
|
|
68
69
|
apkStatus: 'downloading' | 'downloaded' | null;
|
|
69
70
|
marked: boolean;
|
|
70
71
|
applyingUpdate: boolean;
|
|
@@ -509,11 +510,15 @@ export class Pushy {
|
|
|
509
510
|
});
|
|
510
511
|
}
|
|
511
512
|
log(`downloaded ${succeeded} hash:`, hash);
|
|
512
|
-
|
|
513
|
+
const hashInfo: Record<string, any> = {
|
|
513
514
|
name,
|
|
514
515
|
description,
|
|
515
516
|
metaInfo,
|
|
516
|
-
}
|
|
517
|
+
};
|
|
518
|
+
if (sharedState.toHash === hash) {
|
|
519
|
+
hashInfo.debugChannel = true;
|
|
520
|
+
}
|
|
521
|
+
setLocalHashInfo(hash, hashInfo);
|
|
517
522
|
sharedState.downloadedHash = hash;
|
|
518
523
|
return hash;
|
|
519
524
|
};
|
package/src/core.ts
CHANGED
|
@@ -31,11 +31,21 @@ export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
|
|
31
31
|
export const packageVersion: string = PushyConstants.packageVersion;
|
|
32
32
|
export const currentVersion: string = PushyConstants.currentVersion;
|
|
33
33
|
|
|
34
|
+
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
|
35
|
+
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
|
35
|
-
let _currentVersionInfo = {};
|
|
39
|
+
let _currentVersionInfo: Record<string, any> = {};
|
|
40
|
+
let isDebugChannel = false;
|
|
36
41
|
if (currentVersionInfoString) {
|
|
37
42
|
try {
|
|
38
43
|
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
|
44
|
+
if (_currentVersionInfo.debugChannel) {
|
|
45
|
+
isDebugChannel = true;
|
|
46
|
+
delete _currentVersionInfo.debugChannel;
|
|
47
|
+
setLocalHashInfo(currentVersion, _currentVersionInfo);
|
|
48
|
+
}
|
|
39
49
|
} catch (error) {
|
|
40
50
|
console.error(
|
|
41
51
|
'Failed to parse currentVersionInfo:',
|
|
@@ -46,15 +56,13 @@ if (currentVersionInfoString) {
|
|
|
46
56
|
export const currentVersionInfo = _currentVersionInfo;
|
|
47
57
|
|
|
48
58
|
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
|
59
|
+
export const isFirstTimeDebug: boolean = isFirstTime && isDebugChannel;
|
|
49
60
|
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
|
50
61
|
export const isRolledBack: boolean = !!rolledBackVersion;
|
|
51
62
|
|
|
52
63
|
export const buildTime: string = PushyConstants.buildTime;
|
|
53
64
|
let uuid = PushyConstants.uuid;
|
|
54
65
|
|
|
55
|
-
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
|
|
56
|
-
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
|
|
57
|
-
}
|
|
58
66
|
|
|
59
67
|
async function getLocalHashInfo(hash: string) {
|
|
60
68
|
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
package/src/provider.tsx
CHANGED
|
@@ -327,7 +327,9 @@ export const UpdateProvider = ({
|
|
|
327
327
|
Alert.alert(type, JSON.stringify(data));
|
|
328
328
|
};
|
|
329
329
|
if (payload.type === '__rnPushyVersionHash') {
|
|
330
|
-
|
|
330
|
+
const toHash = payload.data;
|
|
331
|
+
sharedState.toHash = toHash;
|
|
332
|
+
checkUpdate({ extra: { toHash } }).then(() => {
|
|
331
333
|
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
|
332
334
|
Alert.alert(
|
|
333
335
|
client.t('alert_info'),
|