Skip to content

Feat / subscription retry logic #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

royschut
Copy link
Collaborator

@royschut royschut commented Apr 22, 2024

(Copy of #483, which was automatically closed when its base PR (#494) was merged, and I couldn't reopen)

Access check retry mechanism

This PR adds a retry mechanism to the access check (reloadActiveSubscription()), to make sure that the UI notices granted access, even if the backend takes longer to process a purchase. This also makes it possible to reduce the initial delay. Note: I've left the initial delay after a subscription switch on 3000ms, because a switch presumably always takes long (it was initially set to 7500).

@royschut royschut force-pushed the feat/subscription-retry-logic branch from 910518f to f162661 Compare April 29, 2024 12:16
@@ -34,7 +34,7 @@ const useOffers = () => {
const switchSubscription = useMutation({
mutationKey: ['switchSubscription'],
mutationFn: checkoutController.switchSubscription,
onSuccess: () => accountController.reloadSubscriptions({ delay: 7500 }), // @todo: Is there a better way to wait?
onSuccess: () => accountController.reloadSubscriptions({ delay: 3000, retry: 10 }), // A subscription switch usually takes at least 3 secs
Copy link
Collaborator

@AntonLantukh AntonLantukh May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@royschut Will it work properly if we already have an "activeSubscription"? I mean the case here when we switch a subscription. So it looks like this condition !activeSubscription && !!retry && retry > 0 won't work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, probably not. We could fix it using the approach proposed by @dbudzins in #483, but that's too large of a refactor for this moment. I have noted this for another moment.

But until that, for now I see two options:

  • We set the initial delay for this case back to 7500, and merge this PR as it is still a step forward
  • We set this PR back into Draft for now

I'm fine with both options. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am good with the first option. Just wanted to make sure this is something you are aware of.

@AntonLantukh AntonLantukh merged commit 065e9c1 into jwplayer:develop May 13, 2024
8 of 9 checks passed
@royschut royschut deleted the feat/subscription-retry-logic branch May 28, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants