Skip to content

Commit aee9345

Browse files
committed
Update version to 10.37.0 in package.json and enhance hash handling in client and core logic
1 parent 6c07aa7 commit aee9345

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.36.6",
3+
"version": "10.37.0",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const defaultClientOptions: ClientOptions = {
6565
export const sharedState: {
6666
progressHandlers: Record<string, EmitterSubscription>;
6767
downloadedHash?: string;
68+
toHash?: string;
6869
apkStatus: 'downloading' | 'downloaded' | null;
6970
marked: boolean;
7071
applyingUpdate: boolean;
@@ -509,11 +510,15 @@ export class Pushy {
509510
});
510511
}
511512
log(`downloaded ${succeeded} hash:`, hash);
512-
setLocalHashInfo(hash, {
513+
const hashInfo: Record<string, any> = {
513514
name,
514515
description,
515516
metaInfo,
516-
});
517+
};
518+
if (sharedState.toHash === hash) {
519+
hashInfo.debugChannel = true;
520+
}
521+
setLocalHashInfo(hash, hashInfo);
517522
sharedState.downloadedHash = hash;
518523
return hash;
519524
};

src/core.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ export const downloadRootDir: string = PushyConstants.downloadRootDir;
3131
export const packageVersion: string = PushyConstants.packageVersion;
3232
export const currentVersion: string = PushyConstants.currentVersion;
3333

34+
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
35+
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
36+
}
37+
3438
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
35-
let _currentVersionInfo = {};
39+
let _currentVersionInfo: Record<string, any> = {};
40+
let isDebugChannel = false;
3641
if (currentVersionInfoString) {
3742
try {
3843
_currentVersionInfo = JSON.parse(currentVersionInfoString);
44+
if (_currentVersionInfo.debugChannel) {
45+
isDebugChannel = true;
46+
delete _currentVersionInfo.debugChannel;
47+
setLocalHashInfo(currentVersion, _currentVersionInfo);
48+
}
3949
} catch (error) {
4050
console.error(
4151
'Failed to parse currentVersionInfo:',
@@ -46,15 +56,13 @@ if (currentVersionInfoString) {
4656
export const currentVersionInfo = _currentVersionInfo;
4757

4858
export const isFirstTime: boolean = PushyConstants.isFirstTime;
59+
export const isFirstTimeDebug: boolean = isFirstTime && isDebugChannel;
4960
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
5061
export const isRolledBack: boolean = !!rolledBackVersion;
5162

5263
export const buildTime: string = PushyConstants.buildTime;
5364
let uuid = PushyConstants.uuid;
5465

55-
export function setLocalHashInfo(hash: string, info: Record<string, any>) {
56-
PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
57-
}
5866

5967
async function getLocalHashInfo(hash: string) {
6068
return JSON.parse(await PushyModule.getLocalHashInfo(hash));

src/provider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ export const UpdateProvider = ({
327327
Alert.alert(type, JSON.stringify(data));
328328
};
329329
if (payload.type === '__rnPushyVersionHash') {
330-
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
330+
const toHash = payload.data;
331+
sharedState.toHash = toHash;
332+
checkUpdate({ extra: { toHash } }).then(() => {
331333
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
332334
Alert.alert(
333335
client.t('alert_info'),

0 commit comments

Comments
 (0)