forked from coracle/flotilla
9df8cee501
Adopts the rewritten welshman API: the removed @welshman/util helpers (Profile/List/Room/Handler/Encryptable) are now Reader/Builder classes in @welshman/domain, and @welshman/app dropped its global singletons for an App instance + app.use(Plugin) registry. - src/app/welshman.ts is now the app bootstrap + session-state module (one shared App instance, multi-account sessions/login, app-wide reactive views) rather than a compat shim re-exporting the old globals. - Rewrote ~100 callers to use app.use(Plugin) directly (thunks, profiles, relays, rooms, zaps, tags, wot, feeds, sync); thunk helpers are now thunk methods. - Added @welshman/domain dependency. - Resolved residual gaps (storage hydration via plugin.onItem/wrapManager/Plaintext, relay-list mutators, search-relay list, outbox #d filter). Best-effort: no toolchain/linking available, so this is not build- or type-checked. Remaining judgment calls are flagged with TODO(welshman-migration). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsMjvv7krpZeHK1Njeneru
114 lines
3.8 KiB
Svelte
114 lines
3.8 KiB
Svelte
<script lang="ts">
|
|
import {getWalletAddress} from "@welshman/util"
|
|
import {session, userProfile} from "@app/welshman"
|
|
import {errorMessage} from "@lib/util"
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
import Button from "@lib/components/Button.svelte"
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
|
import Wallet from "@assets/icons/wallet.svg?dataurl"
|
|
import CheckCircle from "@assets/icons/check-circle.svg?dataurl"
|
|
import {updateProfile} from "@app/profiles"
|
|
import {pushToast} from "@app/toast"
|
|
|
|
const back = () => history.back()
|
|
|
|
// TODO(welshman-migration): `$userProfile` is now a Profile Reader; `.lud16` is
|
|
// a raw-metadata field. Read via `$userProfile?.values?.lud16` once confirmed.
|
|
let address = $state($userProfile?.lud16 || "")
|
|
let loading = $state(false)
|
|
|
|
const walletLud16 = $derived($session?.wallet ? getWalletAddress($session.wallet) : undefined)
|
|
|
|
const useWalletAddress = () => {
|
|
if (walletLud16) {
|
|
address = walletLud16
|
|
}
|
|
}
|
|
|
|
const save = async () => {
|
|
loading = true
|
|
|
|
try {
|
|
// TODO(welshman-migration): `$userProfile` is now a Profile Reader; spreading
|
|
// it copies Reader methods rather than the raw metadata. Use
|
|
// `$userProfile?.values` (cf. WalletAsReceivingAddress) once confirmed.
|
|
const thunk = await updateProfile({
|
|
profile: {
|
|
...$userProfile,
|
|
lud06: undefined,
|
|
lud16: address.trim() || undefined,
|
|
},
|
|
})
|
|
const error = await thunk.waitForError()
|
|
|
|
if (error) {
|
|
pushToast({theme: "error", message: `Failed to update profile: ${errorMessage(error)}`})
|
|
} else {
|
|
back()
|
|
}
|
|
} catch (error) {
|
|
pushToast({theme: "error", message: "Failed to update profile"})
|
|
} finally {
|
|
loading = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<Modal>
|
|
<ModalBody>
|
|
<ModalHeader>
|
|
<ModalTitle>Update Lightning Address</ModalTitle>
|
|
<ModalSubtitle>Update your lightning address for receiving payments.</ModalSubtitle>
|
|
</ModalHeader>
|
|
|
|
<div class="column gap-4">
|
|
<div class="column gap-2">
|
|
<span> Lightning Address </span>
|
|
<input
|
|
type="text"
|
|
placeholder="user@domain.com"
|
|
bind:value={address}
|
|
class="input input-bordered flex w-full"
|
|
disabled={loading} />
|
|
<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>
|
|
|
|
{#if walletLud16 && walletLud16 !== address}
|
|
<div class="card bg-base-200 p-4">
|
|
<div class="flex items-center justify-between gap-3">
|
|
<div class="column gap-1">
|
|
<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>
|
|
</div>
|
|
<Button class="btn btn-outline btn-sm" onclick={useWalletAddress} disabled={loading}>
|
|
Use This
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button class="btn btn-neutral" onclick={back} disabled={loading}>Cancel</Button>
|
|
<Button class="btn btn-primary" onclick={save} disabled={loading}>
|
|
{#if loading}
|
|
<span class="loading loading-spinner loading-sm"></span>
|
|
{:else}
|
|
<Icon icon={CheckCircle} />
|
|
{/if}
|
|
Save Changes
|
|
</Button>
|
|
</ModalFooter>
|
|
</Modal>
|