diff --git a/ui/src/screens/Wallet.svelte b/ui/src/screens/Wallet.svelte index 3627786..bded17e 100644 --- a/ui/src/screens/Wallet.svelte +++ b/ui/src/screens/Wallet.svelte @@ -21,7 +21,10 @@ let wallet = $state(null); let catalog = $state(null); let loading = $state(true); - let busy = $state(false); + // The product whose purchase is in flight, or null. It both guards against a concurrent purchase + // (busy) and scopes the pressed/dimmed visual to the tapped button — not every buy button. + let busyId = $state(null); + const busy = $derived(busyId !== null); // The value awaiting a web-spend warning confirmation (a spend that would draw vk/tg chips). let warnProduct = $state(null); @@ -99,13 +102,13 @@ async function doBuy(p: CatalogProduct) { warnProduct = null; if (busy) return; - busy = true; + busyId = p.productId; try { wallet = await gateway.walletBuy(p.productId); } catch (e) { handleError(e); } finally { - busy = false; + busyId = null; } } @@ -114,7 +117,7 @@ // paying accepts the public offer (linked below the packs). async function onOrder(p: CatalogProduct) { if (busy) return; - busy = true; + busyId = p.productId; try { const order = await gateway.walletOrder(p.productId); if (context === 'vk') { @@ -134,7 +137,7 @@ } catch (e) { handleError(e); } finally { - busy = false; + busyId = null; } } @@ -172,7 +175,9 @@
{p.title} 🪙 {p.chips} - +
{/each} @@ -186,6 +191,7 @@