From 617a0361695321cd5b5fd70e8d1a5a2a1e8fe1fd Mon Sep 17 00:00:00 2001 From: Roy Schut Date: Wed, 28 Feb 2024 16:02:59 +0100 Subject: [PATCH] refactor: make retry delay static to 1500 --- packages/common/src/controllers/AccountController.ts | 8 +++++--- packages/hooks-react/src/useOffers.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/common/src/controllers/AccountController.ts b/packages/common/src/controllers/AccountController.ts index e788462ef..6f4b5ea76 100644 --- a/packages/common/src/controllers/AccountController.ts +++ b/packages/common/src/controllers/AccountController.ts @@ -398,7 +398,7 @@ export default class AccountController { if (delay && delay > 0) { return new Promise((resolve: (value?: unknown) => void) => { setTimeout(() => { - this.reloadSubscriptions().finally(resolve); + this.reloadSubscriptions({ retry }).finally(resolve); }, delay); }); } @@ -418,8 +418,10 @@ export default class AccountController { let pendingOffer: Offer | null = null; - if (!activeSubscription && retry) { - return await this.reloadSubscriptions({ delay: delay || 1000, retry: retry - 1 }); + if (!activeSubscription && retry && retry > 0) { + const retryDelay = 1500; + + return await this.reloadSubscriptions({ delay: retryDelay, retry: retry - 1 }); } // resolve and fetch the pending offer after upgrade/downgrade diff --git a/packages/hooks-react/src/useOffers.ts b/packages/hooks-react/src/useOffers.ts index 4f60cd40c..cd63b9bd3 100644 --- a/packages/hooks-react/src/useOffers.ts +++ b/packages/hooks-react/src/useOffers.ts @@ -34,7 +34,7 @@ const useOffers = () => { const switchSubscription = useMutation({ mutationKey: ['switchSubscription'], mutationFn: checkoutController.switchSubscription, - onSuccess: () => accountController.reloadSubscriptions({ delay: 3000, retry: 3 }), + onSuccess: () => accountController.reloadSubscriptions({ delay: 3000, retry: 5 }), }); useEffect(() => {