diff --git a/package.json b/package.json index c8a0d80..21dfc1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.36.6", + "version": "10.37.0", "description": "react-native hot update", "main": "src/index", "scripts": { diff --git a/src/client.ts b/src/client.ts index 8c4c9ab..6b13770 100644 --- a/src/client.ts +++ b/src/client.ts @@ -65,6 +65,7 @@ const defaultClientOptions: ClientOptions = { export const sharedState: { progressHandlers: Record; downloadedHash?: string; + toHash?: string; apkStatus: 'downloading' | 'downloaded' | null; marked: boolean; applyingUpdate: boolean; @@ -509,11 +510,15 @@ export class Pushy { }); } log(`downloaded ${succeeded} hash:`, hash); - setLocalHashInfo(hash, { + const hashInfo: Record = { name, description, metaInfo, - }); + }; + if (sharedState.toHash === hash) { + hashInfo.debugChannel = true; + } + setLocalHashInfo(hash, hashInfo); sharedState.downloadedHash = hash; return hash; }; diff --git a/src/core.ts b/src/core.ts index 66ef030..713c979 100644 --- a/src/core.ts +++ b/src/core.ts @@ -31,11 +31,21 @@ export const downloadRootDir: string = PushyConstants.downloadRootDir; export const packageVersion: string = PushyConstants.packageVersion; export const currentVersion: string = PushyConstants.currentVersion; +export function setLocalHashInfo(hash: string, info: Record) { + PushyModule.setLocalHashInfo(hash, JSON.stringify(info)); +} + const currentVersionInfoString: string = PushyConstants.currentVersionInfo; -let _currentVersionInfo = {}; +let _currentVersionInfo: Record = {}; +let isDebugChannel = false; if (currentVersionInfoString) { try { _currentVersionInfo = JSON.parse(currentVersionInfoString); + if (_currentVersionInfo.debugChannel) { + isDebugChannel = true; + delete _currentVersionInfo.debugChannel; + setLocalHashInfo(currentVersion, _currentVersionInfo); + } } catch (error) { console.error( 'Failed to parse currentVersionInfo:', @@ -46,15 +56,13 @@ if (currentVersionInfoString) { export const currentVersionInfo = _currentVersionInfo; export const isFirstTime: boolean = PushyConstants.isFirstTime; +export const isFirstTimeDebug: boolean = isFirstTime && isDebugChannel; export const rolledBackVersion: string = PushyConstants.rolledBackVersion; export const isRolledBack: boolean = !!rolledBackVersion; export const buildTime: string = PushyConstants.buildTime; let uuid = PushyConstants.uuid; -export function setLocalHashInfo(hash: string, info: Record) { - PushyModule.setLocalHashInfo(hash, JSON.stringify(info)); -} async function getLocalHashInfo(hash: string) { return JSON.parse(await PushyModule.getLocalHashInfo(hash)); diff --git a/src/provider.tsx b/src/provider.tsx index aaa5f92..3725de9 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -327,7 +327,9 @@ export const UpdateProvider = ({ Alert.alert(type, JSON.stringify(data)); }; if (payload.type === '__rnPushyVersionHash') { - checkUpdate({ extra: { toHash: payload.data } }).then(() => { + const toHash = payload.data; + sharedState.toHash = toHash; + checkUpdate({ extra: { toHash } }).then(() => { if (updateInfoRef.current && updateInfoRef.current.upToDate) { Alert.alert( client.t('alert_info'),