remove claims from default space urls, fix universal link handlers

This commit is contained in:
Jon Staab 2026-07-08 14:33:25 -07:00
parent c139722261
commit f7d0cb7413
3 changed files with 28 additions and 22 deletions

View file

@ -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<Profile>("signup.profile")!)),
relays: [...DEFAULT_RELAYS, ...defaultSpaceUrls],
relays: [...DEFAULT_RELAYS, ...DEFAULT_SPACES],
}),
setSpaces(defaultSpaceUrls),
setSpaces(DEFAULT_SPACES),
])
// Wait for all the thunks to complete

View file

@ -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

View file

@ -135,9 +135,12 @@
netContext.isEventValid = (event: TrustedEvent, url: string) =>
getSetting<string[]>("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())