refactor: simplify success toast handling and refresh logic in CreditsBalanceCard

This commit is contained in:
javayhu 2025-07-13 22:39:28 +08:00
parent 5e877bf45e
commit 1adf3d5dc3

View File

@ -86,18 +86,15 @@ export default function CreditsBalanceCard() {
if (sessionId && !hasHandledSession.current) {
hasHandledSession.current = true;
// Show success toast (delayed to avoid React lifecycle conflicts)
setTimeout(() => {
// Show success toast and refresh data after payment
toast.success(t('creditsAdded'));
}, 0);
// Use setTimeout to ensure async operations complete properly
setTimeout(() => {
// Force refresh credits data to show updated balance
fetchCredits(true);
// Refresh credit stats
fetchCreditStats();
}, 100);
}, 0);
// Clean up URL parameters
const url = new URL(window.location.href);