Skip to content

Commit

Permalink
refactor: make retry delay static to 1500
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Feb 28, 2024
1 parent 8dda5b5 commit 617a036
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/common/src/controllers/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks-react/src/useOffers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 617a036

Please sign in to comment.