mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-01 13:53:11 +08:00
Record local hash info
This commit is contained in:
6
lib/index.d.ts
vendored
6
lib/index.d.ts
vendored
@@ -72,6 +72,12 @@ export function setCustomEndpoints({
|
||||
backupQueryUrl?: string;
|
||||
}): void;
|
||||
|
||||
export function getCurrentVersionInfo(): Promise<{
|
||||
name?: string;
|
||||
description?: string;
|
||||
metaInfo?: string;
|
||||
}>;
|
||||
|
||||
interface ProgressData {
|
||||
hash: string;
|
||||
received: number;
|
||||
|
||||
22
lib/index.js
22
lib/index.js
@@ -21,11 +21,6 @@ if (!Pushy) {
|
||||
throw new Error('react-native-update模块无法加载,请对照安装文档检查配置。');
|
||||
}
|
||||
|
||||
// TODO: save and export current version info
|
||||
// name
|
||||
// description
|
||||
// metaInfo
|
||||
|
||||
export const downloadRootDir = Pushy.downloadRootDir;
|
||||
export const packageVersion = Pushy.packageVersion;
|
||||
export const currentVersion = Pushy.currentVersion;
|
||||
@@ -41,6 +36,18 @@ if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) {
|
||||
);
|
||||
}
|
||||
|
||||
function setLocalHashInfo(hash, info) {
|
||||
Pushy.setLocalHashInfo(hash, JSON.stringify(info));
|
||||
}
|
||||
|
||||
async function getLocalHashInfo(hash) {
|
||||
return JSON.parse(await Pushy.getLocalHashInfo(hash));
|
||||
}
|
||||
|
||||
export async function getCurrentVersionInfo() {
|
||||
return currentVersion ? getLocalHashInfo(currentVersion) : {};
|
||||
}
|
||||
|
||||
const eventEmitter = new NativeEventEmitter(Pushy);
|
||||
|
||||
if (!uuid) {
|
||||
@@ -219,6 +226,11 @@ export async function downloadUpdate(options, eventListeners) {
|
||||
hash: options.hash,
|
||||
});
|
||||
}
|
||||
setLocalHashInfo(options.hash, {
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
metaInfo: options.metaInfo,
|
||||
});
|
||||
progressHandler && progressHandler.remove();
|
||||
downloadedHash = options.hash;
|
||||
return options.hash;
|
||||
|
||||
Reference in New Issue
Block a user