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

add return value for downloadupdate

This commit is contained in:
sunnylqm
2024-11-23 16:09:43 +08:00
parent 9a49025884
commit 2192000d53
5 changed files with 15 additions and 15 deletions

View File

@@ -90,18 +90,20 @@ export const PushyProvider = ({
const downloadUpdate = useCallback(
async (info: CheckResult | undefined = updateInfoRef.current) => {
if (!info || !info.update) {
return;
return false;
}
try {
const hash = await client.downloadUpdate(info, setProgress);
if (!hash) {
return;
return false;
}
stateListener.current && stateListener.current.remove();
if (options.updateStrategy === 'silentAndNow') {
return client.switchVersion(hash);
client.switchVersion(hash);
return true;
} else if (options.updateStrategy === 'silentAndLater') {
return client.switchVersionLater(hash);
client.switchVersionLater(hash);
return true;
}
alertUpdate('提示', '下载完毕,是否立即更新?', [
{
@@ -119,10 +121,12 @@ export const PushyProvider = ({
},
},
]);
return true;
} catch (e: any) {
setLastError(e);
alertError('更新失败', e.message);
throwErrorIfEnabled(e);
return false;
}
},
[
@@ -202,7 +206,8 @@ export const PushyProvider = ({
options.updateStrategy === 'silentAndNow' ||
options.updateStrategy === 'silentAndLater'
) {
return downloadUpdate(info);
downloadUpdate(info);
return;
}
alertUpdate(
'提示',