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 |
|
| 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) |
|
| `hasNip(70)` | whether space content is marked protected (below) |
|
||||||
| `self` | the relay's own pubkey, the trust anchor for relay-signed state |
|
| `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`) |
|
| `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 {events} from "@app/core"
|
||||||
import {ENABLE_ZAPS} from "@app/env"
|
import {ENABLE_ZAPS} from "@app/env"
|
||||||
import {CONTENT_KINDS} from "@app/content"
|
import {CONTENT_KINDS} from "@app/content"
|
||||||
import {deriveIsGroupSpace} from "@app/relays"
|
import {deriveSpaceSupportsRooms} from "@app/relays"
|
||||||
import {makeSpaceChatPath, makeSpacePath} from "@app/routes"
|
import {makeSpaceChatPath, makeSpacePath} from "@app/routes"
|
||||||
import {allNotifications, notifications} from "@app/notifications"
|
import {allNotifications, notifications} from "@app/notifications"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
const {url}: Props = $props()
|
const {url}: Props = $props()
|
||||||
|
|
||||||
const isGroupSpace = deriveIsGroupSpace(url)
|
const supportsRooms = deriveSpaceSupportsRooms(url)
|
||||||
const chatPath = makeSpaceChatPath(url)
|
const chatPath = makeSpaceChatPath(url)
|
||||||
const goalsPath = makeSpacePath(url, "goals")
|
const goalsPath = makeSpacePath(url, "goals")
|
||||||
const threadsPath = makeSpacePath(url, "threads")
|
const threadsPath = makeSpacePath(url, "threads")
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
<SecondaryNavItem href={makeSpacePath(url, "about")}>
|
<SecondaryNavItem href={makeSpacePath(url, "about")}>
|
||||||
<Icon icon={Home} /> Space Details
|
<Icon icon={Home} /> Space Details
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
{#if !$isGroupSpace}
|
{#if !$supportsRooms}
|
||||||
<SecondaryNavItem href={chatPath} notification={$notifications.has(chatPath)}>
|
<SecondaryNavItem href={chatPath} notification={$notifications.has(chatPath)}>
|
||||||
<Icon icon={ChatRound} /> Chat
|
<Icon icon={ChatRound} /> Chat
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
<Icon icon={Revote} /> Polls
|
<Icon icon={Revote} /> Polls
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $isGroupSpace}
|
{#if $supportsRooms}
|
||||||
<SecondaryNavItem onclick={openSearch}>
|
<SecondaryNavItem onclick={openSearch}>
|
||||||
<Icon icon={Magnifier} /> Search
|
<Icon icon={Magnifier} /> Search
|
||||||
</SecondaryNavItem>
|
</SecondaryNavItem>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
import SpaceMenuRoomItem from "@app/components/SpaceMenuRoomItem.svelte"
|
import SpaceMenuRoomItem from "@app/components/SpaceMenuRoomItem.svelte"
|
||||||
import RoomCreate from "@app/components/RoomCreate.svelte"
|
import RoomCreate from "@app/components/RoomCreate.svelte"
|
||||||
import {deriveUserCanCreateRoom} from "@app/management"
|
import {deriveUserCanCreateRoom} from "@app/management"
|
||||||
import {deriveIsGroupSpace} from "@app/relays"
|
import {deriveSpaceSupportsRooms} from "@app/relays"
|
||||||
import {RoomType, deriveUserRooms, deriveOtherRooms, displayRoom} from "@app/rooms"
|
import {RoomType, deriveUserRooms, deriveOtherRooms, displayRoom} from "@app/rooms"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
const {url, mobile = false}: Props = $props()
|
const {url, mobile = false}: Props = $props()
|
||||||
|
|
||||||
const isGroupSpace = deriveIsGroupSpace(url)
|
const supportsRooms = deriveSpaceSupportsRooms(url)
|
||||||
const userRooms = deriveUserRooms(url)
|
const userRooms = deriveUserRooms(url)
|
||||||
const otherRooms = deriveOtherRooms(url, RoomType.Text)
|
const otherRooms = deriveOtherRooms(url, RoomType.Text)
|
||||||
const otherVoiceRooms = deriveOtherRooms(url, RoomType.Voice)
|
const otherVoiceRooms = deriveOtherRooms(url, RoomType.Voice)
|
||||||
|
|
@ -95,7 +95,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/snippet}
|
{/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}
|
{#if mobile}
|
||||||
<div class="card space-menu__card flex flex-col gap-1">
|
<div class="card space-menu__card flex flex-col gap-1">
|
||||||
{@render content()}
|
{@render content()}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import {CONTENT_KINDS, makeCommentFilter} from "@app/content"
|
||||||
import {getIsMuted, userSettingsValues} from "@app/settings"
|
import {getIsMuted, userSettingsValues} from "@app/settings"
|
||||||
import {Chats} from "@app/chats"
|
import {Chats} from "@app/chats"
|
||||||
import {dufflepud, DUFFLEPUD_URL} from "@app/env"
|
import {dufflepud, DUFFLEPUD_URL} from "@app/env"
|
||||||
import {isGroupSpace} from "@app/relays"
|
import {spaceSupportsRooms} from "@app/relays"
|
||||||
import {activeSpaceUrls} from "@app/rooms"
|
import {activeSpaceUrls} from "@app/rooms"
|
||||||
import {getHttpAuthHeader} from "@app/signer"
|
import {getHttpAuthHeader} from "@app/signer"
|
||||||
import {kv} from "@app/storage"
|
import {kv} from "@app/storage"
|
||||||
|
|
@ -214,7 +214,7 @@ export const latestActivityByPath = derived(
|
||||||
[
|
[
|
||||||
activeSpaceUrls,
|
activeSpaceUrls,
|
||||||
fromApp($app => $app.use(Chats).index.$),
|
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 => $app.use(Relays).index.$),
|
||||||
fromApp(
|
fromApp(
|
||||||
$app =>
|
$app =>
|
||||||
|
|
@ -240,7 +240,7 @@ export const latestActivityByPath = derived(
|
||||||
for (const url of $activeSpaceUrls) {
|
for (const url of $activeSpaceUrls) {
|
||||||
const events = sortEventsDesc((eventsByIdByUrl.get(url) || new Map()).values())
|
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)) {
|
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
|
// 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)) {
|
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.
|
// 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)))
|
derived(relays.get().one(url), $relay => Boolean($relay?.hasNip(29)))
|
||||||
|
|
||||||
const livekitUrl = (url: string) =>
|
const livekitUrl = (url: string) =>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import {
|
||||||
} from "@app/core"
|
} from "@app/core"
|
||||||
import {PLATFORM_RELAYS} from "@app/env"
|
import {PLATFORM_RELAYS} from "@app/env"
|
||||||
import {allowPubkeys, deriveSpacePermissions, deriveUserIsSpaceStaff} from "@app/management"
|
import {allowPubkeys, deriveSpacePermissions, deriveUserIsSpaceStaff} from "@app/management"
|
||||||
import {isGroupSpace} from "@app/relays"
|
import {spaceSupportsRooms} from "@app/relays"
|
||||||
import {makeRoomPath, makeSpaceChatPath} from "@app/routes"
|
import {makeRoomPath, makeSpaceChatPath} from "@app/routes"
|
||||||
import {loadSendDelay} from "@app/settings"
|
import {loadSendDelay} from "@app/settings"
|
||||||
|
|
||||||
|
|
@ -300,7 +300,7 @@ export const deriveUserRoomSearch = () =>
|
||||||
type Option = {url: string; h?: string; path: string; name: string; isFavorite: boolean}
|
type Option = {url: string; h?: string; path: string; name: string; isFavorite: boolean}
|
||||||
|
|
||||||
const options = $userSpaceUrls.flatMap((url): Option[] => {
|
const options = $userSpaceUrls.flatMap((url): Option[] => {
|
||||||
if (isGroupSpace(url)) {
|
if (spaceSupportsRooms(url)) {
|
||||||
const favorites = new Set($userRoomList?.roomsForUrl(url) ?? [])
|
const favorites = new Set($userRoomList?.roomsForUrl(url) ?? [])
|
||||||
|
|
||||||
return ($roomsByUrl.get(url) ?? []).map(({h}) => ({
|
return ($roomsByUrl.get(url) ?? []).map(({h}) => ({
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import type {Maybe} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {app} from "@app/core"
|
import {app} from "@app/core"
|
||||||
import {navigate, pushModal} from "@app/modal"
|
import {navigate, pushModal} from "@app/modal"
|
||||||
import {isGroupSpace} from "@app/relays"
|
import {spaceSupportsRooms} from "@app/relays"
|
||||||
import {makeSpaceChatPath} from "@app/routes"
|
import {makeSpaceChatPath} from "@app/routes"
|
||||||
import {pushToast} from "@app/toast"
|
import {pushToast} from "@app/toast"
|
||||||
import ShareDialog from "@app/components/Share.svelte"
|
import ShareDialog from "@app/components/Share.svelte"
|
||||||
|
|
@ -31,7 +31,7 @@ export const shareTo = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
export const shareEvent = (url: string, noun: string, event: TrustedEvent) => {
|
export const shareEvent = (url: string, noun: string, event: TrustedEvent) => {
|
||||||
if (isGroupSpace(url)) {
|
if (spaceSupportsRooms(url)) {
|
||||||
pushModal(ShareEvent, {url, noun, event})
|
pushModal(ShareEvent, {url, noun, event})
|
||||||
} else {
|
} else {
|
||||||
shareTo(makeSpaceChatPath(url), {type: "event", value: event})
|
shareTo(makeSpaceChatPath(url), {type: "event", value: event})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue