1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-01 13:53:11 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Record local hash info

This commit is contained in:
sunnylqm
2021-10-04 23:19:22 +08:00
parent d32d395a2a
commit bf1701031b
5 changed files with 54 additions and 25 deletions

6
lib/index.d.ts vendored
View File

@@ -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;

View File

@@ -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;