fix zapper loading

This commit is contained in:
Jon Staab
2025-10-27 13:36:29 -07:00
parent 0b98197a86
commit 4583c4e028

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import type {Snippet} from "svelte" import type {Snippet} from "svelte"
import type {TrustedEvent} from "@welshman/util" import type {TrustedEvent} from "@welshman/util"
import {session, deriveZapperForPubkey} from "@welshman/app" import {session, loadZapperForPubkey} from "@welshman/app"
import Button from "@lib/components/Button.svelte" import Button from "@lib/components/Button.svelte"
import Zap from "@app/components/Zap.svelte" import Zap from "@app/components/Zap.svelte"
import InfoZapperError from "@app/components/InfoZapperError.svelte" import InfoZapperError from "@app/components/InfoZapperError.svelte"
@@ -18,19 +18,29 @@
const {url, event, children, replaceState, ...props}: Props = $props() const {url, event, children, replaceState, ...props}: Props = $props()
const zapper = deriveZapperForPubkey(event.pubkey) const zapperPromise = loadZapperForPubkey(event.pubkey)
const onClick = () => { const onClick = async () => {
if (!$zapper?.allowsNostr) { loading = true
pushModal(InfoZapperError, {url, pubkey: event.pubkey, eventId: event.id}, {replaceState})
} else if ($session?.wallet) { try {
pushModal(Zap, {url, pubkey: event.pubkey, eventId: event.id}, {replaceState}) const zapper = await zapperPromise
} else {
pushModal(WalletConnect, {}, {replaceState}) if (!zapper?.allowsNostr) {
pushModal(InfoZapperError, {url, pubkey: event.pubkey, eventId: event.id}, {replaceState})
} else if ($session?.wallet) {
pushModal(Zap, {url, pubkey: event.pubkey, eventId: event.id}, {replaceState})
} else {
pushModal(WalletConnect, {}, {replaceState})
}
} finally {
loading = false
} }
} }
let loading = $state(false)
</script> </script>
<Button onclick={onClick} {...props}> <Button onclick={onClick} disabled={loading} {...props}>
{@render children?.()} {@render children?.()}
</Button> </Button>