Skip to content

Commit a9c3606

Browse files
committed
add onpackageexpired
1 parent 05738ec commit a9c3606

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.28.1",
3+
"version": "10.29.0",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/provider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const UpdateProvider = ({
171171
return;
172172
}
173173
const rollout = info.config?.rollout?.[packageVersion];
174-
if (rollout) {
174+
if (info.update && rollout) {
175175
if (!isInRollout(rollout)) {
176176
log(`not in ${rollout}% rollout, ignored`);
177177
return;
@@ -182,6 +182,13 @@ export const UpdateProvider = ({
182182
updateInfoRef.current = info;
183183
setUpdateInfo(info);
184184
if (info.expired) {
185+
if (
186+
options.onPackageExpired &&
187+
(await options.onPackageExpired(info)) === false
188+
) {
189+
log('onPackageExpired returned false, skipping');
190+
return;
191+
}
185192
const { downloadUrl } = info;
186193
if (downloadUrl && Pushy.apkStatus === null) {
187194
if (options.updateStrategy === 'silentAndNow') {

src/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface ClientOptions {
9292
beforeCheckUpdate?: () => Promise<boolean>;
9393
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
9494
afterDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
95+
onPackageExpired?: (info: CheckResult) => Promise<boolean>;
9596
}
9697

9798
export interface UpdateTestPayload {

0 commit comments

Comments
 (0)