Fix join page on white labeled instance

This commit is contained in:
Jon Staab 2026-07-03 17:01:37 -07:00
parent 9ca73eb162
commit e52cbcc23b
4 changed files with 43 additions and 39 deletions

View file

@ -33,9 +33,10 @@
type Props = {
invite: string
back?: () => void
hideHeader?: boolean
}
let {invite = "", back = () => history.back()}: Props = $props()
let {invite = "", back = () => history.back(), hideHeader}: Props = $props()
const toggleScanner = () => {
showScanner = !showScanner
@ -95,27 +96,29 @@
<Modal tag="form" onsubmit={preventDefault(join)}>
<ModalBody>
<ModalHeader>
<ModalTitle>Join a Space</ModalTitle>
<ModalSubtitle
>Enter a relay URL or invite link below to join an existing space.</ModalSubtitle>
</ModalHeader>
<Field>
{#snippet label()}
<p>Invite Link*</p>
{/snippet}
{#snippet input()}
<label class="input flex w-full items-center gap-2">
<Icon icon={LinkRound} />
<input bind:value={invite} class="grow" type="text" />
<Button onclick={toggleScanner} class="flex items-center justify-center">
<Icon icon={QrCode} />
</Button>
</label>
{/snippet}
</Field>
{#if showScanner}
<Scanner onscan={onScan} />
{#if !hideHeader}
<ModalHeader>
<ModalTitle>Join a Space</ModalTitle>
<ModalSubtitle
>Enter a relay URL or invite link below to join an existing space.</ModalSubtitle>
</ModalHeader>
<Field>
{#snippet label()}
<p>Invite Link*</p>
{/snippet}
{#snippet input()}
<label class="input flex w-full items-center gap-2">
<Icon icon={LinkRound} />
<input bind:value={invite} class="grow" type="text" />
<Button onclick={toggleScanner} class="flex items-center justify-center">
<Icon icon={QrCode} />
</Button>
</label>
{/snippet}
</Field>
{#if showScanner}
<Scanner onscan={onScan} />
{/if}
{/if}
{#if inviteData}
<div class="-my-4">

View file

@ -20,7 +20,7 @@ import {
getRelaysFromList,
} from "@welshman/util"
import {makeChatId} from "@app/chats"
import {entityLink, PLATFORM_URL} from "@app/env"
import {entityLink, PLATFORM_URL, PLATFORM_RELAYS} from "@app/env"
import {encodeRelay, hasNip29} from "@app/relays"
import {DM_KINDS} from "@app/content"
import {ROOM} from "@app/groups"
@ -101,6 +101,14 @@ export const goToSpace = (url: string, hash = "") => {
return goto(makeSpacePath(url) + hash, {replaceState: true})
}
export const goToHome = () => {
if (PLATFORM_RELAYS.length > 0) {
goToSpace(PLATFORM_RELAYS[0], get(page).url.hash)
} else {
goto("/home" + get(page).url.hash)
}
}
// Content types, events
export const makeMessagePath = (url: string, event: TrustedEvent) => {

View file

@ -1,14 +1,5 @@
<script lang="ts">
import {goto} from "$app/navigation"
import {page} from "$app/stores"
import {goToSpace} from "@app/routes"
import {PLATFORM_RELAYS} from "@app/env"
import {goToHome} from "@app/routes"
$effect(() => {
if (PLATFORM_RELAYS.length > 0) {
goToSpace(PLATFORM_RELAYS[0], $page.url.hash)
} else {
goto("/home" + $page.url.hash)
}
})
$effect(goToHome)
</script>

View file

@ -1,18 +1,20 @@
<script lang="ts">
import {page} from "$app/stores"
import {goto} from "$app/navigation"
import Dialog from "@lib/components/Dialog.svelte"
import SpaceInviteAccept from "@app/components/SpaceInviteAccept.svelte"
const close = () => goto("/home")
import {goToHome} from "@app/routes"
import {modal} from "@app/modal"
const children = {
component: SpaceInviteAccept,
props: {
hideHeader: true,
invite: $page.url.href,
back: close,
back: goToHome,
},
}
</script>
<Dialog {children} onClose={close} />
{#if !$modal}
<Dialog {children} onClose={goToHome} />
{/if}