Optionally protect profiles

This commit is contained in:
Jon Staab
2025-04-15 09:36:39 -07:00
parent a64eaba45c
commit 91689e5b90
5 changed files with 63 additions and 16 deletions
+10 -4
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import type {Profile} from "@welshman/util"
import {PROFILE, createProfile, createEvent} from "@welshman/util"
import {PROFILE, createProfile, makeProfile, createEvent} from "@welshman/util"
import {loginWithNip01, publishThunk} from "@welshman/app"
import Button from "@lib/components/Button.svelte"
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
@@ -12,15 +12,21 @@
const {secret}: Props = $props()
const onsubmit = (profile: Profile) => {
const initialValues = {
profile: makeProfile(),
shouldBroadcast: true,
}
const onsubmit = ({profile, shouldBroadcast}: {profile: Profile; shouldBroadcast: boolean}) => {
const event = createEvent(PROFILE, createProfile(profile))
const relays = shouldBroadcast ? INDEXER_RELAYS : []
loginWithNip01(secret)
publishThunk({event, relays: INDEXER_RELAYS})
publishThunk({event, relays})
}
</script>
<ProfileEditForm hideAddress {onsubmit}>
<ProfileEditForm hideAddress {initialValues} {onsubmit}>
{#snippet footer()}
<Button type="submit" class="btn btn-primary">Create Account</Button>
{/snippet}