-
Notifications
You must be signed in to change notification settings - Fork 176
Fix: payment methods not updated after adding it #2060
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
Conversation
if (value) { | ||
methods = { | ||
...methods, | ||
total: methods.total + 1, | ||
paymentMethods: [...methods.paymentMethods, event.detail] | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly adds the card to the passed on object. this is done to avoid a flash of layout shift if we used invalidate(Dependencies.PAYMENT_METHODS)
because we use a Skeleton loader, the load is pretty quick so it would look very off. Doing this way, there's just a UI swap instead of a network request.
]); | ||
$: isOnOnboarding = page.route?.id?.includes('/(console)/onboarding'); | ||
|
||
$: projects = isOnOnboarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoids a failed network request when there are no orgs and the user is on onboarding path.
|
||
// fixes an edge case where | ||
// the org is not available for some reason! | ||
await invalidate(Dependencies.CREATE_ORGANIZATION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is because we use const { organizations } = await parent()
, which is loaded at the top level +layout.ts
. Children below it don't load it so the first project creation can fail sometimes for billing checks because there's no org in the list. This just invalidates and loads all of them again. Perf cost is very minimal.
bind:value={paymentMethodId} | ||
bind:taxId> | ||
bind:methods={paymentMethods}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binds in order to update/mutate the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, make sure it's tested on staging
What does this PR do?
Adding a new card required a page reload on
change-plan
route due to the payment methods being loaded in svelte context which didn't trigger a reload without a reactive update. This PR fixes that and directly updates the underlying payment list modal to avoid a skeleton loader flash if we used a streamed promise or reloaded via svelte context await.Test Plan
Manual.
Related PRs and Issues
N/A.
Have you read the Contributing Guidelines on issues?
Yes.