8000 Fix: payment methods not updated after adding it by ItzNotABug · Pull Request #2060 · appwrite/console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 5 commits into from
Jun 30, 2025
Merged

Conversation

ItzNotABug
Copy link
Member

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.

@ItzNotABug ItzNotABug self-assigned this Jun 29, 2025
@ItzNotABug ItzNotABug requested a review from lohanidamodar June 29, 2025 05:41
Comment on lines +24 to +30
if (value) {
methods = {
...methods,
total: methods.total + 1,
paymentMethods: [...methods.paymentMethods, event.detail]
};
}
Copy link
Member Author

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
Copy link
Member Author

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);
Copy link
Member Author

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}>
Copy link
Member Author

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.

Copy link
Member
@lohanidamodar lohanidamodar left a comment
A363

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

@ItzNotABug ItzNotABug merged commit f08bad0 into main Jun 30, 2025
2 checks passed
@ItzNotABug ItzNotABug deleted the fix-payments-state branch June 30, 2025 07:25
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.

2 participants
0