Compare commits
1 Commits
dev
...
a2a3c52e89
| Author | SHA1 | Date | |
|---|---|---|---|
| a2a3c52e89 |
@@ -1,15 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Snippet} from "svelte"
|
import type {Snippet} from "svelte"
|
||||||
|
import {get} from "svelte/store"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {once} from "@welshman/lib"
|
import {once} from "@welshman/lib"
|
||||||
|
import {pubkey} from "@welshman/app"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||||
import SpaceMenu from "@app/components/SpaceMenu.svelte"
|
import SpaceMenu from "@app/components/SpaceMenu.svelte"
|
||||||
import SpaceAuthError from "@app/components/SpaceAuthError.svelte"
|
import SpaceAuthError from "@app/components/SpaceAuthError.svelte"
|
||||||
import SpaceTrustRelay from "@app/components/SpaceTrustRelay.svelte"
|
import SpaceTrustRelay from "@app/components/SpaceTrustRelay.svelte"
|
||||||
|
import SpaceJoin from "@app/components/SpaceJoin.svelte"
|
||||||
import {pushModal} from "@app/util/modal"
|
import {pushModal} from "@app/util/modal"
|
||||||
import {makeSpacePath} from "@app/util/routes"
|
import {makeSpacePath} from "@app/util/routes"
|
||||||
import {decodeRelay, relaysPendingTrust} from "@app/core/state"
|
import {decodeRelay, relaysPendingTrust, userSpaceUrls, loadUserGroupList} from "@app/core/state"
|
||||||
import {deriveRelayAuthError} from "@app/core/commands"
|
import {deriveRelayAuthError} from "@app/core/commands"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -28,6 +31,8 @@
|
|||||||
|
|
||||||
const showPendingTrust = once(() => pushModal(SpaceTrustRelay, {url}, {noEscape: true}))
|
const showPendingTrust = once(() => pushModal(SpaceTrustRelay, {url}, {noEscape: true}))
|
||||||
|
|
||||||
|
const joinPrompted = new Set<string>()
|
||||||
|
|
||||||
// Watch for relay errors and notify the user
|
// Watch for relay errors and notify the user
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if ($authError) {
|
if ($authError) {
|
||||||
@@ -36,6 +41,49 @@
|
|||||||
showPendingTrust()
|
showPendingTrust()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Direct links skip Discover — prompt to join when relay is not in the user's space list.
|
||||||
|
$effect(() => {
|
||||||
|
const spaceUrl = url
|
||||||
|
const currentPubkey = get(pubkey)
|
||||||
|
|
||||||
|
if (!currentPubkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($userSpaceUrls.includes(spaceUrl) || $authError || $relaysPendingTrust.includes(spaceUrl)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let cancelled = false
|
||||||
|
|
||||||
|
void loadUserGroupList().then(() => {
|
||||||
|
if (cancelled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (get(pubkey) !== currentPubkey) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
get(userSpaceUrls).includes(spaceUrl) ||
|
||||||
|
get(authError) ||
|
||||||
|
get(relaysPendingTrust).includes(spaceUrl) ||
|
||||||
|
joinPrompted.has(spaceUrl)
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
joinPrompted.add(spaceUrl)
|
||||||
|
pushModal(SpaceJoin, {url: spaceUrl})
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true
|
||||||
|
joinPrompted.delete(spaceUrl)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $page.url.pathname === makeSpacePath(url)}
|
{#if $page.url.pathname === makeSpacePath(url)}
|
||||||
|
|||||||
Reference in New Issue
Block a user