mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 10:21:37 +08:00
add return value for downloadupdate
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.15.3",
|
||||
"version": "10.16.0",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
@@ -69,7 +69,7 @@
|
||||
"fs-extra": "^11.2.0",
|
||||
"jest": "^29.7.0",
|
||||
"pod-install": "^0.2.2",
|
||||
"prettier": "^3",
|
||||
"prettier": "^2",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.73",
|
||||
"ts-jest": "^29.2.5",
|
||||
|
@@ -25,7 +25,7 @@ export const PushyContext = createContext<{
|
||||
switchVersionLater: () => Promise<void>;
|
||||
markSuccess: () => void;
|
||||
dismissError: () => void;
|
||||
downloadUpdate: () => Promise<void>;
|
||||
downloadUpdate: () => Promise<boolean | void>;
|
||||
downloadAndInstallApk: (url: string) => Promise<void>;
|
||||
getCurrentVersionInfo: () => Promise<{
|
||||
name?: string;
|
||||
|
@@ -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(
|
||||
'提示',
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
# bun ./bun.lockb --hash: F85D92799AFF262A-7ffac79fcf85c731-89BCC22943BFB132-7245a25635ad115c
|
||||
# bun ./bun.lockb --hash: 2058EE9308759DAF-113fc986523daaf8-AF755908B492C9F6-6a66f4ed28448ee4
|
||||
|
||||
|
||||
"@ampproject/remapping@^2.2.0":
|
||||
@@ -8022,16 +8022,11 @@ prelude-ls@^1.2.1:
|
||||
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
|
||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||
|
||||
prettier@>=2:
|
||||
prettier@>=2, prettier@^2:
|
||||
version "2.8.8"
|
||||
resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz"
|
||||
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
|
||||
|
||||
prettier@^3:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz"
|
||||
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
|
||||
|
||||
prettier-linter-helpers@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz"
|
||||
|
Reference in New Issue
Block a user