Rename isGroupSpace to spaceSupportsRooms
This commit is contained in:
parent
0968e18e77
commit
c463e0e2db
7 changed files with 17 additions and 17 deletions
|
|
@ -41,7 +41,7 @@ domain `Relay`. These fields drive protocol decisions:
|
|||
|
||||
| Read | Decides |
|
||||
|---|---|
|
||||
| `hasNip(29)` | whether the space has rooms, read through `isGroupSpace(url)` / `deriveIsGroupSpace(url)` in `src/app/relays.ts`. Without it everything lives in the space chat (`makeSpaceChatPath`): `shareEvent` (`src/app/share.ts`), room search, notification grouping, `SpaceMenuNavItems`, `SpaceMenuRooms` |
|
||||
| `hasNip(29)` | whether the space has rooms, read through `spaceSupportsRooms(url)` / `deriveSpaceSupportsRooms(url)` in `src/app/relays.ts`. Without it everything lives in the space chat (`makeSpaceChatPath`): `shareEvent` (`src/app/share.ts`), room search, notification grouping, `SpaceMenuNavItems`, `SpaceMenuRooms` |
|
||||
| `hasNip(70)` | whether space content is marked protected (below) |
|
||||
| `self` | the relay's own pubkey, the trust anchor for relay-signed state |
|
||||
| `pubkey` | the space's owner, who writes space-wide content that has no other author (`deriveUserIsSpaceOwner`) |
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
import {events} from "@app/core"
|
||||
import {ENABLE_ZAPS} from "@app/env"
|
||||
import {CONTENT_KINDS} from "@app/content"
|
||||
import {deriveIsGroupSpace} from "@app/relays"
|
||||
import {deriveSpaceSupportsRooms} from "@app/relays"
|
||||
import {makeSpaceChatPath, makeSpacePath} from "@app/routes"
|
||||
import {allNotifications, notifications} from "@app/notifications"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const isGroupSpace = deriveIsGroupSpace(url)
|
||||
const supportsRooms = deriveSpaceSupportsRooms(url)
|
||||
const chatPath = makeSpaceChatPath(url)
|
||||
const goalsPath = makeSpacePath(url, "goals")
|
||||
const threadsPath = makeSpacePath(url, "threads")
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
<SecondaryNavItem href={makeSpacePath(url, "about")}>
|
||||
<Icon icon={Home} /> Space Details
|
||||
</SecondaryNavItem>
|
||||
{#if !$isGroupSpace}
|
||||
{#if !$supportsRooms}
|
||||
<SecondaryNavItem href={chatPath} notification={$notifications.has(chatPath)}>
|
||||
<Icon icon={ChatRound} /> Chat
|
||||
</SecondaryNavItem>
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
<Icon icon={Revote} /> Polls
|
||||
</SecondaryNavItem>
|
||||
{/if}
|
||||
{#if $isGroupSpace}
|
||||
{#if $supportsRooms}
|
||||
<SecondaryNavItem onclick={openSearch}>
|
||||
<Icon icon={Magnifier} /> Search
|
||||
</SecondaryNavItem>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
import SpaceMenuRoomItem from "@app/components/SpaceMenuRoomItem.svelte"
|
||||
import RoomCreate from "@app/components/RoomCreate.svelte"
|
||||
import {deriveUserCanCreateRoom} from "@app/management"
|
||||
import {deriveIsGroupSpace} from "@app/relays"
|
||||
import {deriveSpaceSupportsRooms} from "@app/relays"
|
||||
import {RoomType, deriveUserRooms, deriveOtherRooms, displayRoom} from "@app/rooms"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
const {url, mobile = false}: Props = $props()
|
||||
|
||||
const isGroupSpace = deriveIsGroupSpace(url)
|
||||
const supportsRooms = deriveSpaceSupportsRooms(url)
|
||||
const userRooms = deriveUserRooms(url)
|
||||
const otherRooms = deriveOtherRooms(url, RoomType.Text)
|
||||
const otherVoiceRooms = deriveOtherRooms(url, RoomType.Voice)
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#if $isGroupSpace && ($userRooms.length > 0 || $otherRooms.length > 0 || $otherVoiceRooms.length > 0 || $canCreateRoom)}
|
||||
{#if $supportsRooms && ($userRooms.length > 0 || $otherRooms.length > 0 || $otherVoiceRooms.length > 0 || $canCreateRoom)}
|
||||
{#if mobile}
|
||||
<div class="card space-menu__card flex flex-col gap-1">
|
||||
{@render content()}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import {CONTENT_KINDS, makeCommentFilter} from "@app/content"
|
|||
import {getIsMuted, userSettingsValues} from "@app/settings"
|
||||
import {Chats} from "@app/chats"
|
||||
import {dufflepud, DUFFLEPUD_URL} from "@app/env"
|
||||
import {isGroupSpace} from "@app/relays"
|
||||
import {spaceSupportsRooms} from "@app/relays"
|
||||
import {activeSpaceUrls} from "@app/rooms"
|
||||
import {getHttpAuthHeader} from "@app/signer"
|
||||
import {kv} from "@app/storage"
|
||||
|
|
@ -214,7 +214,7 @@ export const latestActivityByPath = derived(
|
|||
[
|
||||
activeSpaceUrls,
|
||||
fromApp($app => $app.use(Chats).index.$),
|
||||
// Only here to recompute once a relay's NIP-11 says whether it's a group space
|
||||
// Only here to recompute once a relay's NIP-11 says whether the space supports rooms
|
||||
fromApp($app => $app.use(Relays).index.$),
|
||||
fromApp(
|
||||
$app =>
|
||||
|
|
@ -240,7 +240,7 @@ export const latestActivityByPath = derived(
|
|||
for (const url of $activeSpaceUrls) {
|
||||
const events = sortEventsDesc((eventsByIdByUrl.get(url) || new Map()).values())
|
||||
|
||||
if (isGroupSpace(url)) {
|
||||
if (spaceSupportsRooms(url)) {
|
||||
for (const [h, [event]] of groupBy(e => tagValue(tagSpec("h"), e.tags), events)) {
|
||||
// A muted room is left out entirely, so it can't light up its own badge or the space's
|
||||
if (h && !getIsMuted($settings, url, h)) {
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ export const deriveSocketStatus = (url: string) =>
|
|||
)
|
||||
|
||||
// A space that isn't a NIP-29 relay has no rooms, only one space-wide chat.
|
||||
export const isGroupSpace = (url: string) => Boolean(relays.get().get(url)?.hasNip(29))
|
||||
export const spaceSupportsRooms = (url: string) => Boolean(relays.get().get(url)?.hasNip(29))
|
||||
|
||||
export const deriveIsGroupSpace = (url: string) =>
|
||||
export const deriveSpaceSupportsRooms = (url: string) =>
|
||||
derived(relays.get().one(url), $relay => Boolean($relay?.hasNip(29)))
|
||||
|
||||
const livekitUrl = (url: string) =>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {
|
|||
} from "@app/core"
|
||||
import {PLATFORM_RELAYS} from "@app/env"
|
||||
import {allowPubkeys, deriveSpacePermissions, deriveUserIsSpaceStaff} from "@app/management"
|
||||
import {isGroupSpace} from "@app/relays"
|
||||
import {spaceSupportsRooms} from "@app/relays"
|
||||
import {makeRoomPath, makeSpaceChatPath} from "@app/routes"
|
||||
import {loadSendDelay} from "@app/settings"
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ export const deriveUserRoomSearch = () =>
|
|||
type Option = {url: string; h?: string; path: string; name: string; isFavorite: boolean}
|
||||
|
||||
const options = $userSpaceUrls.flatMap((url): Option[] => {
|
||||
if (isGroupSpace(url)) {
|
||||
if (spaceSupportsRooms(url)) {
|
||||
const favorites = new Set($userRoomList?.roomsForUrl(url) ?? [])
|
||||
|
||||
return ($roomsByUrl.get(url) ?? []).map(({h}) => ({
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import type {Maybe} from "@welshman/lib"
|
|||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {app} from "@app/core"
|
||||
import {navigate, pushModal} from "@app/modal"
|
||||
import {isGroupSpace} from "@app/relays"
|
||||
import {spaceSupportsRooms} from "@app/relays"
|
||||
import {makeSpaceChatPath} from "@app/routes"
|
||||
import {pushToast} from "@app/toast"
|
||||
import ShareDialog from "@app/components/Share.svelte"
|
||||
|
|
@ -31,7 +31,7 @@ export const shareTo = async (
|
|||
}
|
||||
|
||||
export const shareEvent = (url: string, noun: string, event: TrustedEvent) => {
|
||||
if (isGroupSpace(url)) {
|
||||
if (spaceSupportsRooms(url)) {
|
||||
pushModal(ShareEvent, {url, noun, event})
|
||||
} else {
|
||||
shareTo(makeSpaceChatPath(url), {type: "event", value: event})
|
||||
|
|
|
|||
Loading…
Reference in a new issue