feat: prompt SpaceJoin when opening unjoined space via direct link
This commit is contained in:
@@ -772,6 +772,8 @@ export const getSpaceRoomsFromGroupList = (url: string, groupList: List | undefi
|
|||||||
|
|
||||||
export const userGroupList = makeUserData(groupListsByPubkey, loadGroupList)
|
export const userGroupList = makeUserData(groupListsByPubkey, loadGroupList)
|
||||||
|
|
||||||
|
export const deriveUserGroupList = userGroupList
|
||||||
|
|
||||||
export const loadUserGroupList = makeUserLoader(loadGroupList)
|
export const loadUserGroupList = makeUserLoader(loadGroupList)
|
||||||
|
|
||||||
export const userSpaceUrls = derived(userGroupList, getSpaceUrlsFromGroupList)
|
export const userSpaceUrls = derived(userGroupList, getSpaceUrlsFromGroupList)
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
|
<script module lang="ts">
|
||||||
|
const joinPrompted = new Set<string>()
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {Snippet} from "svelte"
|
import type {Snippet} from "svelte"
|
||||||
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,
|
||||||
|
deriveUserGroupList,
|
||||||
|
relaysPendingTrust,
|
||||||
|
userSpaceUrls,
|
||||||
|
} from "@app/core/state"
|
||||||
import {deriveRelayAuthError} from "@app/core/commands"
|
import {deriveRelayAuthError} from "@app/core/commands"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -36,6 +47,27 @@
|
|||||||
showPendingTrust()
|
showPendingTrust()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Direct links skip Discover — prompt to join when relay is not in the user's space list.
|
||||||
|
const shouldPromptJoin = $derived.by(() => {
|
||||||
|
void $deriveUserGroupList
|
||||||
|
|
||||||
|
return (
|
||||||
|
Boolean($pubkey) &&
|
||||||
|
!$userSpaceUrls.includes(url) &&
|
||||||
|
!$authError &&
|
||||||
|
!$relaysPendingTrust.includes(url)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (!shouldPromptJoin || joinPrompted.has(url)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
joinPrompted.add(url)
|
||||||
|
pushModal(SpaceJoin, {url})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $page.url.pathname === makeSpacePath(url)}
|
{#if $page.url.pathname === makeSpacePath(url)}
|
||||||
|
|||||||
Reference in New Issue
Block a user