1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-23 09:38:52 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

add currentversioninfo

This commit is contained in:
sunnylqm
2025-09-15 23:46:19 +08:00
parent f7be8a4d71
commit bfb520bd07
9 changed files with 47 additions and 23 deletions

View File

@@ -28,11 +28,17 @@ export const UpdateContext = createContext<{
dismissError: () => void;
downloadUpdate: () => Promise<boolean | void>;
downloadAndInstallApk: (url: string) => Promise<void>;
// @deprecated use currentVersionInfo instead
getCurrentVersionInfo: () => Promise<{
name?: string;
description?: string;
metaInfo?: string;
}>;
currentVersionInfo: {
name?: string;
description?: string;
metaInfo?: string;
} | null;
parseTestQrCode: (code: string) => boolean;
restartApp: () => Promise<void>;
currentHash: string;

View File

@@ -30,6 +30,21 @@ const PushyConstants = isTurboModuleEnabled
export const downloadRootDir: string = PushyConstants.downloadRootDir;
export const packageVersion: string = PushyConstants.packageVersion;
export const currentVersion: string = PushyConstants.currentVersion;
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
let _currentVersionInfo = {};
if (currentVersionInfoString) {
try {
_currentVersionInfo = JSON.parse(currentVersionInfoString);
} catch (error) {
console.error(
'Failed to parse currentVersionInfo:',
currentVersionInfoString,
);
}
}
export const currentVersionInfo = _currentVersionInfo;
export const isFirstTime: boolean = PushyConstants.isFirstTime;
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
export const isRolledBack: boolean = typeof rolledBackVersion === 'string';
@@ -45,6 +60,7 @@ async function getLocalHashInfo(hash: string) {
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
}
// @deprecated use currentVersionInfo instead
export async function getCurrentVersionInfo(): Promise<{
name?: string;
description?: string;

View File

@@ -13,7 +13,7 @@ import {
Linking,
} from 'react-native';
import { Pushy, Cresc, sharedState } from './client';
import { currentVersion, packageVersion, getCurrentVersionInfo } from './core';
import { currentVersion, packageVersion, getCurrentVersionInfo, currentVersionInfo } from './core';
import {
CheckResult,
MixedCheckResult,
@@ -400,6 +400,7 @@ export const UpdateProvider = ({
progress,
downloadAndInstallApk,
getCurrentVersionInfo,
currentVersionInfo,
parseTestQrCode,
restartApp,
}}>