2025-09-15 13:11:57 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {getWalletAddress} from "@welshman/util"
|
2026-03-06 22:18:05 +00:00
|
|
|
import {errorMessage} from "@lib/util"
|
2025-09-15 13:11:57 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-06-24 20:56:53 +00:00
|
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
2025-09-15 13:11:57 +00:00
|
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
2026-02-02 18:09:14 +00:00
|
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
|
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
2025-09-15 13:11:57 +00:00
|
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
2026-01-30 22:14:12 +00:00
|
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
|
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
2025-09-15 13:11:57 +00:00
|
|
|
import Wallet from "@assets/icons/wallet.svg?dataurl"
|
|
|
|
|
import CheckCircle from "@assets/icons/check-circle.svg?dataurl"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {pushToast} from "@app/toast"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {profiles, user} from "@app/core"
|
|
|
|
|
import {wallet} from "@app/lightning"
|
2025-09-15 13:11:57 +00:00
|
|
|
|
|
|
|
|
const back = () => history.back()
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const walletLud16 = $derived($wallet ? getWalletAddress($wallet) : undefined)
|
2025-09-15 13:11:57 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
let address = $state($profiles.get($user.pubkey)?.lnurl() || "")
|
|
|
|
|
let loading = $state(false)
|
2025-09-15 13:11:57 +00:00
|
|
|
|
|
|
|
|
const useWalletAddress = () => {
|
|
|
|
|
if (walletLud16) {
|
|
|
|
|
address = walletLud16
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const save = async () => {
|
2026-03-06 22:18:05 +00:00
|
|
|
loading = true
|
|
|
|
|
|
2025-09-15 13:11:57 +00:00
|
|
|
try {
|
2026-07-28 16:16:26 +00:00
|
|
|
const command = await $profiles.update(writer =>
|
|
|
|
|
writer.update({lud06: undefined, lud16: address.trim() || undefined}),
|
2026-03-06 22:18:05 +00:00
|
|
|
)
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const error = await command.publish().waitForError()
|
|
|
|
|
|
2026-03-06 22:18:05 +00:00
|
|
|
if (error) {
|
|
|
|
|
pushToast({theme: "error", message: `Failed to update profile: ${errorMessage(error)}`})
|
|
|
|
|
} else {
|
|
|
|
|
back()
|
|
|
|
|
}
|
2025-09-15 13:11:57 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
pushToast({theme: "error", message: "Failed to update profile"})
|
|
|
|
|
} finally {
|
2026-03-06 22:18:05 +00:00
|
|
|
loading = false
|
2025-09-15 13:11:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-01-30 22:14:12 +00:00
|
|
|
<Modal>
|
|
|
|
|
<ModalBody>
|
|
|
|
|
<ModalHeader>
|
2026-02-02 18:09:14 +00:00
|
|
|
<ModalTitle>Update Lightning Address</ModalTitle>
|
|
|
|
|
<ModalSubtitle>Update your lightning address for receiving payments.</ModalSubtitle>
|
2026-01-30 22:14:12 +00:00
|
|
|
</ModalHeader>
|
2025-09-15 13:11:57 +00:00
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="flex flex-col gap-4">
|
|
|
|
|
<div class="flex flex-col gap-2">
|
2026-01-30 22:14:12 +00:00
|
|
|
<span> Lightning Address </span>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="user@domain.com"
|
|
|
|
|
bind:value={address}
|
2026-06-24 20:56:53 +00:00
|
|
|
class="input flex w-full"
|
2026-03-06 22:18:05 +00:00
|
|
|
disabled={loading} />
|
2026-01-30 22:14:12 +00:00
|
|
|
<p class="text-xs opacity-75">
|
|
|
|
|
You can enter one manually or use your connected wallet's address (if available). Leave
|
|
|
|
|
empty to remove your lightning address
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-09-15 13:11:57 +00:00
|
|
|
|
2026-01-30 22:14:12 +00:00
|
|
|
{#if walletLud16 && walletLud16 !== address}
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="card card-sm bg-surface p-4">
|
2026-01-30 22:14:12 +00:00
|
|
|
<div class="flex items-center justify-between gap-3">
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="flex flex-col gap-1">
|
2026-01-30 22:14:12 +00:00
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<Icon icon={Wallet} size={4} />
|
|
|
|
|
<span class="text-sm font-medium">Wallet Address</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p class="text-xs opacity-75">{walletLud16}</p>
|
2025-09-15 13:11:57 +00:00
|
|
|
</div>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button
|
|
|
|
|
class="button button-outline button-sm"
|
|
|
|
|
onclick={useWalletAddress}
|
|
|
|
|
disabled={loading}>
|
2026-01-30 22:14:12 +00:00
|
|
|
Use This
|
|
|
|
|
</Button>
|
2025-09-15 13:11:57 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-30 22:14:12 +00:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</ModalBody>
|
2025-09-15 13:11:57 +00:00
|
|
|
<ModalFooter>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button class="button button-neutral" onclick={back} disabled={loading}>Cancel</Button>
|
|
|
|
|
<Button class="button button-primary" onclick={save} disabled={loading}>
|
2026-03-06 22:18:05 +00:00
|
|
|
{#if loading}
|
2026-06-24 20:56:53 +00:00
|
|
|
<Spinner size="sm" />
|
2025-09-15 13:11:57 +00:00
|
|
|
{:else}
|
|
|
|
|
<Icon icon={CheckCircle} />
|
|
|
|
|
{/if}
|
|
|
|
|
Save Changes
|
|
|
|
|
</Button>
|
|
|
|
|
</ModalFooter>
|
2026-01-30 22:14:12 +00:00
|
|
|
</Modal>
|