From f7d0cb7413d246f7959509fd5d87075634fd2121 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 8 Jul 2026 14:33:25 -0700 Subject: [PATCH] remove claims from default space urls, fix universal link handlers --- src/app/components/SignUp.svelte | 17 ++++------------- src/app/env.ts | 6 +----- src/routes/+layout.svelte | 27 +++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/app/components/SignUp.svelte b/src/app/components/SignUp.svelte index 885e9403..c3a0ce1c 100644 --- a/src/app/components/SignUp.svelte +++ b/src/app/components/SignUp.svelte @@ -48,30 +48,21 @@ const login = () => pushModal(LogIn) const completeSignup = async () => { - // Join all default spaces first - const defaultSpaceUrls = await Promise.all( - DEFAULT_SPACES.map(async ([url, claim]) => { - await attemptRelayAccess(url, claim) - - return url - }), - ) - // Add default outbox/inbox/messaging relays, profile, spaces const thunks = await Promise.all([ publishThunk({ event: makeEvent(RELAYS, {tags: DEFAULT_RELAYS.map(url => ["r", url])}), - relays: [...INDEXER_RELAYS, ...DEFAULT_RELAYS, ...defaultSpaceUrls], + relays: [...INDEXER_RELAYS, ...DEFAULT_RELAYS, ...DEFAULT_SPACES], }), publishThunk({ event: makeEvent(MESSAGING_RELAYS, {tags: DEFAULT_MESSAGING_RELAYS.map(url => ["r", url])}), - relays: [...DEFAULT_RELAYS, ...defaultSpaceUrls], + relays: [...DEFAULT_RELAYS, ...DEFAULT_SPACES], }), publishThunk({ event: makeEvent(PROFILE, createProfile(getKey("signup.profile")!)), - relays: [...DEFAULT_RELAYS, ...defaultSpaceUrls], + relays: [...DEFAULT_RELAYS, ...DEFAULT_SPACES], }), - setSpaces(defaultSpaceUrls), + setSpaces(DEFAULT_SPACES), ]) // Wait for all the thunks to complete diff --git a/src/app/env.ts b/src/app/env.ts index 42e0cac1..fa441c23 100644 --- a/src/app/env.ts +++ b/src/app/env.ts @@ -51,11 +51,7 @@ export const POMADE_SIGNERS = fromCsv(import.meta.env.VITE_POMADE_SIGNERS) export const DEFAULT_BLOSSOM_SERVERS = fromCsv(import.meta.env.VITE_DEFAULT_BLOSSOM_SERVERS) -export const DEFAULT_SPACES = fromCsv(import.meta.env.VITE_DEFAULT_SPACES).map(item => { - const [url, claim = ""] = item.split("|") - - return [normalizeRelayUrl(url), claim] -}) +export const DEFAULT_SPACES = fromCsv(import.meta.env.VITE_DEFAULT_SPACES).map(normalizeRelayUrl) export const DEFAULT_PUBKEYS = import.meta.env.VITE_DEFAULT_PUBKEYS diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index d4386ff5..acd8a9e8 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -135,9 +135,12 @@ netContext.isEventValid = (event: TrustedEvent, url: string) => getSetting("trusted_relays").includes(url) || verifyEvent(event) - // Listen for deep link events - App.addListener("appUrlOpen", async (event: URLOpenListenerEvent) => { - const url = new URL(event.url) + // Handle a deep link (universal/app link or custom scheme). Used for both + // warm-start links (via the appUrlOpen event) and cold-start links (via + // getLaunchUrl below) so the invite relay/claim query params are preserved + // in either case. + const handleDeepLink = (rawUrl: string) => { + const url = new URL(rawUrl) const relay = url.searchParams.get("relay") const id = url.searchParams.get("id") @@ -163,7 +166,12 @@ const target = `${url.pathname}${url.search}${url.hash}` goto(target, {replaceState: false, noScroll: false}) - }) + } + + // Listen for deep link events. Capacitor only emits this from onNewIntent, so + // it fires when the app is already running (warm start). Cold-start links are + // handled by getLaunchUrl in the setup block below. + App.addListener("appUrlOpen", (event: URLOpenListenerEvent) => handleDeepLink(event.url)) // Handle back button on mobile App.addListener("backButton", () => { @@ -221,6 +229,17 @@ // Wait for critical storage data only await storageSync.ready + // Handle cold-start deep links. When a link launches the app from a killed + // state the intent arrives via onCreate, so Capacitor never emits + // appUrlOpen for it — the URL is only reachable through getLaunchUrl. + // Without this, invite links opened while the app is closed lose their + // relay/claim params and the space is never joined. + const launch = await App.getLaunchUrl() + + if (launch?.url) { + handleDeepLink(launch.url) + } + // Close the database connection on reload unsubscribers.push(() => db.close())