Tweak room search and owner display

This commit is contained in:
Jon Staab
2025-06-04 20:42:28 -07:00
parent 7d617d8399
commit d262da39e5
2 changed files with 29 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import cx from 'classnames'
import {preventDefault} from "@lib/html" import {preventDefault} from "@lib/html"
import Button from "@lib/components/Button.svelte" import Button from "@lib/components/Button.svelte"
import ProfileName from "@app/components/ProfileName.svelte" import ProfileName from "@app/components/ProfileName.svelte"
@@ -8,13 +9,14 @@
type Props = { type Props = {
pubkey: string pubkey: string
url?: string url?: string
unstyled?: boolean
} }
const {pubkey, url}: Props = $props() const {pubkey, url, unstyled}: Props = $props()
const openProfile = () => pushModal(ProfileDetail, {pubkey, url}) const openProfile = () => pushModal(ProfileDetail, {pubkey, url})
</script> </script>
<Button onclick={preventDefault(openProfile)} class="link-content"> <Button onclick={preventDefault(openProfile)} class={cx({'link-content': !unstyled})}>
@<ProfileName {pubkey} {url} /> @<ProfileName {pubkey} {url} />
</Button> </Button>

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import {page} from "$app/stores" import {page} from "$app/stores"
import {displayRelayUrl} from "@welshman/util" import {displayRelayUrl, MESSAGE, THREAD} from "@welshman/util"
import {deriveRelay} from "@welshman/app" import {deriveRelay, pubkey} from "@welshman/app"
import {AuthStatus, SocketStatus} from "@welshman/net" import {AuthStatus, SocketStatus} from "@welshman/net"
import {fade} from "@lib/transition" import {fade} from "@lib/transition"
import Icon from "@lib/components/Icon.svelte" import Icon from "@lib/components/Icon.svelte"
@@ -10,6 +10,7 @@
import PageBar from "@lib/components/PageBar.svelte" import PageBar from "@lib/components/PageBar.svelte"
import PageContent from "@lib/components/PageContent.svelte" import PageContent from "@lib/components/PageContent.svelte"
import StatusIndicator from "@lib/components/StatusIndicator.svelte" import StatusIndicator from "@lib/components/StatusIndicator.svelte"
import ProfileLink from "@app/components/ProfileLink.svelte"
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte" import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
import ProfileLatest from "@app/components/ProfileLatest.svelte" import ProfileLatest from "@app/components/ProfileLatest.svelte"
import ChannelName from "@app/components/ChannelName.svelte" import ChannelName from "@app/components/ChannelName.svelte"
@@ -26,6 +27,7 @@
deriveOtherRooms, deriveOtherRooms,
userRoomsByUrl, userRoomsByUrl,
deriveSocket, deriveSocket,
deriveEventsForUrl,
} from "@app/state" } from "@app/state"
import {makeChatPath, makeThreadPath, makeCalendarPath, makeRoomPath} from "@app/routes" import {makeChatPath, makeThreadPath, makeCalendarPath, makeRoomPath} from "@app/routes"
import {notifications} from "@app/notifications" import {notifications} from "@app/notifications"
@@ -38,6 +40,7 @@
const otherRooms = deriveOtherRooms(url) const otherRooms = deriveOtherRooms(url)
const threadsPath = makeThreadPath(url) const threadsPath = makeThreadPath(url)
const calendarPath = makeCalendarPath(url) const calendarPath = makeCalendarPath(url)
const mentions = deriveEventsForUrl(url, [{'#p': [$pubkey!], kinds: [MESSAGE, THREAD]}])
const joinSpace = () => pushModal(SpaceJoin, {url}) const joinSpace = () => pushModal(SpaceJoin, {url})
@@ -45,7 +48,7 @@
let roomSearchQuery = $state("") let roomSearchQuery = $state("")
const pubkey = $derived($relay?.profile?.pubkey) const owner = $derived($relay?.profile?.pubkey)
const filteredRooms = $derived(() => { const filteredRooms = $derived(() => {
if (!roomSearchQuery) return [...$userRooms, ...$otherRooms] if (!roomSearchQuery) return [...$userRooms, ...$otherRooms]
@@ -77,8 +80,8 @@
<Icon icon="login-2" /> <Icon icon="login-2" />
Join Space Join Space
</Button> </Button>
{:else if pubkey} {:else if owner}
<Link class="btn btn-primary btn-sm" href={makeChatPath([pubkey])}> <Link class="btn btn-primary btn-sm" href={makeChatPath([owner])}>
<Icon icon="letter" /> <Icon icon="letter" />
Contact Owner Contact Owner
</Link> </Link>
@@ -103,22 +106,14 @@
</div> </div>
</div> </div>
</div> </div>
<div class="min-w-0 flex-1"> <div class="min-w-0 flex flex-col gap-1">
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold"> <h1 class="ellipsize whitespace-nowrap text-2xl font-bold">
<RelayName {url} /> <RelayName {url} />
</h1> </h1>
<p class="ellipsize mb-2 text-sm opacity-75">{displayRelayUrl(url)}</p> <p class="ellipsize text-sm opacity-75">{displayRelayUrl(url)}</p>
{#if $relay?.profile?.pubkey}
<p class="text-sm opacity-60">
<Icon icon="user-rounded" size={4} class="mr-1 inline" />
Relay Admin: {$relay.profile.pubkey.slice(0, 8)}...{$relay.profile.pubkey.slice(-8)}
</p>
{/if}
</div> </div>
</div> </div>
<div class="mt-4"> <RelayDescription {url} />
<RelayDescription {url} />
</div>
</div> </div>
<div class="card2 bg-alt md:hidden"> <div class="card2 bg-alt md:hidden">
<h3 class="mb-4 flex items-center gap-2 text-lg font-semibold"> <h3 class="mb-4 flex items-center gap-2 text-lg font-semibold">
@@ -151,15 +146,16 @@
</div> </div>
</Link> </Link>
{#if $userRooms.length + $otherRooms.length > 10} {#if $userRooms.length + $otherRooms.length > 10}
<div class="mt-4"> <label class="input input-sm input-bordered flex flex-grow items-center gap-2">
<Icon icon="magnifer" size={4} />
<input <input
bind:value={roomSearchQuery}
class="grow"
type="text" type="text"
placeholder="Search rooms..." placeholder="Search rooms..." />
class="input input-sm mb-2 w-full" </label>
bind:value={roomSearchQuery} />
</div>
{/if} {/if}
{#each ($userRooms.length + $otherRooms.length > 10 ? filteredRooms() : [...$userRooms, ...$otherRooms]).slice(0, 10) as room (room)} {#each filteredRooms() as room (room)}
{@const roomPath = makeRoomPath(url, room)} {@const roomPath = makeRoomPath(url, room)}
{@const channel = $channelsById.get(makeChannelId(url, room))} {@const channel = $channelsById.get(makeChannelId(url, room))}
<Link href={roomPath} class="btn btn-neutral btn-sm relative w-full justify-start"> <Link href={roomPath} class="btn btn-neutral btn-sm relative w-full justify-start">
@@ -251,6 +247,11 @@
{#if $relay?.profile} {#if $relay?.profile}
{@const {software, version, supported_nips, limitation} = $relay.profile} {@const {software, version, supported_nips, limitation} = $relay.profile}
<div class="flex flex-wrap gap-1"> <div class="flex flex-wrap gap-1">
{#if owner}
<div class="badge badge-neutral">
<span class="ellipsize">Administrator: <ProfileLink unstyled pubkey={owner} /></span>
</div>
{/if}
{#if $relay?.profile?.contact} {#if $relay?.profile?.contact}
<div class="badge badge-neutral"> <div class="badge badge-neutral">
<span class="ellipsize">Contact: {$relay.profile.contact}</span> <span class="ellipsize">Contact: {$relay.profile.contact}</span>
@@ -290,13 +291,13 @@
{/if} {/if}
</div> </div>
</div> </div>
{#if pubkey} {#if owner}
<div class="card2 bg-alt"> <div class="card2 bg-alt">
<h3 class="mb-4 flex items-center gap-2 text-lg font-semibold"> <h3 class="mb-4 flex items-center gap-2 text-lg font-semibold">
<Icon icon="user-rounded" /> <Icon icon="user-rounded" />
Latest Updates Latest Updates
</h3> </h3>
<ProfileLatest {url} {pubkey}> <ProfileLatest {url} pubkey={owner}>
{#snippet fallback()} {#snippet fallback()}
<p class="text-sm opacity-60">No recent posts from the relay admin</p> <p class="text-sm opacity-60">No recent posts from the relay admin</p>
{/snippet} {/snippet}