Fix profile publishing on email sign up
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {clearModals} from "@app/util/modal"
|
||||
import {PROTECTED} from "@app/core/state"
|
||||
import {initProfile} from "@app/core/commands"
|
||||
|
||||
type Props = {
|
||||
secret: string
|
||||
@@ -22,19 +23,8 @@
|
||||
const back = () => history.back()
|
||||
|
||||
const next = () => {
|
||||
const template = createProfile(profile)
|
||||
|
||||
// Start out protected by default
|
||||
template.tags.push(PROTECTED)
|
||||
|
||||
const event = makeEvent(PROFILE, template)
|
||||
|
||||
// Log in first, then publish
|
||||
loginWithNip01(secret)
|
||||
|
||||
// Don't publish anywhere yet, wait until they join a space
|
||||
publishThunk({event, relays: []})
|
||||
|
||||
initProfile(profile)
|
||||
clearModals()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {initProfile} from "@app/core/commands"
|
||||
import {clearModals} from "@app/util/modal"
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
@@ -23,7 +24,7 @@
|
||||
clientOptions: ClientOptions
|
||||
}
|
||||
|
||||
const {email, clientOptions}: Props = $props()
|
||||
const {email, profile, clientOptions}: Props = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
@@ -36,6 +37,7 @@
|
||||
try {
|
||||
loginWithPomade(clientOptions.group.group_pk.slice(2), clientOptions)
|
||||
pushToast({message: "Successfully logged in!"})
|
||||
initProfile(profile)
|
||||
setChecked("*")
|
||||
clearModals()
|
||||
} finally {
|
||||
|
||||
@@ -754,6 +754,18 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
||||
|
||||
// Update Profile
|
||||
|
||||
export const initProfile = (profile: Profile) => {
|
||||
const template = createProfile(profile)
|
||||
|
||||
// Start out protected by default
|
||||
template.tags.push(PROTECTED)
|
||||
|
||||
const event = makeEvent(PROFILE, template)
|
||||
|
||||
// Don't publish anywhere yet, wait until they join a space
|
||||
return publishThunk({event, relays: []})
|
||||
}
|
||||
|
||||
export const updateProfile = async ({
|
||||
profile,
|
||||
shouldBroadcast = !getTag(PROTECTED, profile.event?.tags || []),
|
||||
|
||||
Reference in New Issue
Block a user