mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-23 09:38:52 +08:00
add currentversioninfo
This commit is contained in:
@@ -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;
|
||||
|
16
src/core.ts
16
src/core.ts
@@ -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;
|
||||
|
@@ -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,
|
||||
}}>
|
||||
|
Reference in New Issue
Block a user