diff --git a/src/app/components/SignUp.svelte b/src/app/components/SignUp.svelte index f6a395b4..faa55aa2 100644 --- a/src/app/components/SignUp.svelte +++ b/src/app/components/SignUp.svelte @@ -37,21 +37,21 @@ const login = () => pushModal(LogIn) - const completeSignup = () => { + const completeSignup = async () => { // Add default outbox/inbox relays - publishThunk({ + await publishThunk({ event: makeEvent(RELAYS, {tags: DEFAULT_RELAYS.map(url => ["r", url])}), relays: [...INDEXER_RELAYS, ...DEFAULT_RELAYS], - }) + }).complete // Add default messaging relays - publishThunk({ + await publishThunk({ event: makeEvent(MESSAGING_RELAYS, {tags: DEFAULT_MESSAGING_RELAYS.map(url => ["r", url])}), relays: DEFAULT_RELAYS, - }) + }).complete // Save the user's profile - initProfile(getKey("signup.profile")!) + await initProfile(getKey("signup.profile")!).complete // Don't show any notifications for old content setChecked("*") @@ -65,23 +65,23 @@ start: () => pushModal(SignUpEmail, {next: flows.email.profile}), profile: () => pushModal(SignUpProfile, {next: flows.email.complete}), complete: () => pushModal(SignUpComplete, {next: flows.email.finalize}), - finalize: () => { + finalize: async () => { const email = getKey("signup.email")! const clientOptions = getKey("signup.clientOptions")! loginWithPomade(clientOptions, email) - completeSignup() + await completeSignup() }, }, nostr: { start: () => pushModal(SignUpProfile, {next: flows.nostr.key}), key: () => pushModal(SignUpKey, {next: flows.nostr.complete}), complete: () => pushModal(SignUpComplete, {next: flows.nostr.finalize}), - finalize: () => { + finalize: async () => { const secret = getKey("signup.secret")! loginWithNip01(secret) - completeSignup() + await completeSignup() }, }, } diff --git a/src/app/components/SpaceInviteAccept.svelte b/src/app/components/SpaceInviteAccept.svelte index 158563f9..4047534b 100644 --- a/src/app/components/SpaceInviteAccept.svelte +++ b/src/app/components/SpaceInviteAccept.svelte @@ -71,7 +71,7 @@ await addSpaceMembership(url) await goto(makeSpacePath(url), {replaceState: true}) - broadcastUserData([url]) + await broadcastUserData([url]) relaysMostlyRestricted.update(dissoc(url)) pushToast({message: "Welcome to the space!"}) } diff --git a/src/app/components/SpaceJoin.svelte b/src/app/components/SpaceJoin.svelte index b684fd24..b1919b17 100644 --- a/src/app/components/SpaceJoin.svelte +++ b/src/app/components/SpaceJoin.svelte @@ -59,7 +59,7 @@ await addSpaceMembership(url) await goto(makeSpacePath(url), {replaceState: true}) - broadcastUserData([url]) + await broadcastUserData([url]) relaysMostlyRestricted.update(dissoc(url)) pushToast({message: "Welcome to the space!"}) } catch (e) { diff --git a/src/app/core/commands.ts b/src/app/core/commands.ts index cfcaf3a8..37987b42 100644 --- a/src/app/core/commands.ts +++ b/src/app/core/commands.ts @@ -83,6 +83,7 @@ import { SETTINGS, PROTECTED, INDEXER_RELAYS, + DEFAULT_RELAYS, DEFAULT_BLOSSOM_SERVERS, userSpaceUrls, userSettingsValues, @@ -125,7 +126,8 @@ export const prependParent = ( export const broadcastUserData = async (relays: string[]) => { const authors = [pubkey.get()!] - const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS, PROFILE] + // Profile is published during onboarding, so space joins should not rebroadcast it. + const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS] const events = repository.query([{kinds, authors}]) for (const event of events) { @@ -678,6 +680,10 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) => // Update Profile export const initProfile = (profile: Profile) => { + const router = Router.get() + const userRelays = router.FromUser().getUrls() + const relays = userRelays.length ? userRelays : DEFAULT_RELAYS + const template = createProfile(profile) // Start out protected by default @@ -685,8 +691,7 @@ export const initProfile = (profile: Profile) => { const event = makeEvent(PROFILE, template) - // Don't publish anywhere yet, wait until they join a space - return publishThunk({event, relays: []}) + return publishThunk({event, relays}) } export const updateProfile = ({