flotilla/src/routes/spaces/[relay]/+page.svelte

139 lines
4.8 KiB
Svelte
Raw Normal View History

2024-09-23 20:10:15 +00:00
<script lang="ts">
import {page} from "$app/stores"
2024-10-31 19:24:40 +00:00
import {deriveRelay} from "@welshman/app"
2024-09-23 20:10:15 +00:00
import Icon from "@lib/components/Icon.svelte"
2024-10-31 19:24:40 +00:00
import Link from "@lib/components/Link.svelte"
import Divider from "@lib/components/Divider.svelte"
2024-10-09 23:11:23 +00:00
import PageBar from "@lib/components/PageBar.svelte"
2024-11-15 22:03:54 +00:00
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
2024-10-31 19:24:40 +00:00
import ProfileFeed from "@app/components/ProfileFeed.svelte"
2024-12-10 01:04:39 +00:00
import ChannelName from "@app/components/ChannelName.svelte"
2024-10-31 19:24:40 +00:00
import RelayName from "@app/components/RelayName.svelte"
import RelayDescription from "@app/components/RelayDescription.svelte"
2024-12-10 21:38:34 +00:00
import {
decodeRelay,
channelIsLocked,
makeChannelId,
channelsById,
deriveUserRooms,
deriveOtherRooms,
} from "@app/state"
2024-11-19 00:33:20 +00:00
import {makeChatPath, makeRoomPath, makeSpacePath} from "@app/routes"
2024-09-23 20:10:15 +00:00
2024-10-21 17:30:12 +00:00
const url = decodeRelay($page.params.relay)
2024-10-31 19:24:40 +00:00
const relay = deriveRelay(url)
2024-12-10 21:02:41 +00:00
const userRooms = deriveUserRooms(url)
const otherRooms = deriveOtherRooms(url)
2024-09-23 20:10:15 +00:00
2024-10-31 19:24:40 +00:00
$: pubkey = $relay?.profile?.pubkey
2024-09-23 20:10:15 +00:00
</script>
2024-10-31 19:24:40 +00:00
<div class="relative flex flex-col">
2024-10-09 23:11:23 +00:00
<PageBar>
<div slot="icon" class="center">
2024-10-31 19:24:40 +00:00
<Icon icon="home-smile" />
2024-09-23 20:10:15 +00:00
</div>
2024-10-31 19:24:40 +00:00
<strong slot="title">Home</strong>
2024-10-23 21:20:24 +00:00
<div slot="action" class="row-2">
2024-10-31 19:24:40 +00:00
{#if pubkey}
<Link class="btn btn-primary btn-sm" href={makeChatPath([pubkey])}>
<Icon icon="letter" />
Contact Owner
</Link>
{/if}
2024-11-15 22:03:54 +00:00
<MenuSpaceButton {url} />
2024-10-23 16:45:06 +00:00
</div>
2024-10-09 23:11:23 +00:00
</PageBar>
2024-11-01 22:08:27 +00:00
<div class="col-2 p-2">
<div class="card2 bg-alt col-4 text-left">
<div class="relative flex gap-4">
<div class="relative">
<div class="avatar relative">
<div
class="center !flex h-12 w-12 min-w-12 rounded-full border-2 border-solid border-base-300 bg-base-300">
{#if $relay?.profile?.icon}
<img alt="" src={$relay.profile.icon} />
{:else}
<Icon icon="ghost" size={5} />
{/if}
2024-10-31 19:24:40 +00:00
</div>
</div>
</div>
2024-11-01 22:08:27 +00:00
<div>
<h2 class="ellipsize whitespace-nowrap text-xl">
<RelayName {url} />
</h2>
<p class="text-sm opacity-75">{url}</p>
</div>
2024-10-31 19:24:40 +00:00
</div>
2024-11-01 22:08:27 +00:00
<RelayDescription {url} />
{#if $relay?.profile}
{@const {software, version, supported_nips, limitation} = $relay.profile}
<div class="flex flex-wrap gap-1">
{#if limitation?.auth_required}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral">
<span class="ellipsize">Authentication Required</span>
</p>
2024-11-01 22:08:27 +00:00
{/if}
{#if limitation?.payment_required}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral"><span class="ellipsize">Payment Required</span></p>
2024-11-01 22:08:27 +00:00
{/if}
{#if limitation?.min_pow_difficulty}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral">
<span class="ellipsize">Requires PoW {limitation?.min_pow_difficulty}</span>
</p>
2024-11-01 22:08:27 +00:00
{/if}
{#if supported_nips}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral">
<span class="ellipsize">NIPs: {supported_nips.join(", ")}</span>
</p>
2024-11-01 22:08:27 +00:00
{/if}
{#if software}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral"><span class="ellipsize">Software: {software}</span></p>
2024-11-01 22:08:27 +00:00
{/if}
{#if version}
2024-11-16 16:04:09 +00:00
<p class="badge badge-neutral"><span class="ellipsize">Version: {version}</span></p>
2024-11-01 22:08:27 +00:00
{/if}
</div>
{/if}
</div>
2024-12-10 01:04:39 +00:00
<div class="grid grid-cols-3 gap-2">
2024-12-10 21:02:41 +00:00
<Link href={makeSpacePath(url, "threads")} class="btn btn-primary justify-start border-none">
2024-11-19 00:33:20 +00:00
<Icon icon="notes-minimalistic" /> Threads
</Link>
2024-12-10 21:02:41 +00:00
{#each $userRooms as room (room)}
2024-12-10 01:04:39 +00:00
<Link
2024-12-10 21:02:41 +00:00
href={makeRoomPath(url, room)}
class="btn btn-neutral flex-nowrap justify-start whitespace-nowrap border-none">
2024-12-10 21:38:34 +00:00
{#if channelIsLocked($channelsById.get(makeChannelId(url, room)))}
<Icon icon="lock" size={4} />
{:else}
<Icon icon="hashtag" />
{/if}
2024-12-10 21:02:41 +00:00
<div class="min-w-0 overflow-hidden text-ellipsis">
<ChannelName {url} {room} />
</div>
</Link>
{/each}
{#each $otherRooms as room (room)}
<Link
href={makeRoomPath(url, room)}
2024-12-10 01:04:39 +00:00
class="bg-alt btn btn-neutral flex-nowrap justify-start whitespace-nowrap border-none">
2024-12-10 21:38:34 +00:00
{#if channelIsLocked($channelsById.get(makeChannelId(url, room)))}
<Icon icon="lock" size={4} />
{:else}
<Icon icon="hashtag" />
{/if}
2024-12-10 01:04:39 +00:00
<div class="min-w-0 overflow-hidden text-ellipsis">
2024-12-10 21:02:41 +00:00
<ChannelName {url} {room} />
2024-12-10 01:04:39 +00:00
</div>
2024-11-19 00:33:20 +00:00
</Link>
{/each}
</div>
2024-11-01 22:08:27 +00:00
{#if pubkey}
2024-10-31 19:24:40 +00:00
<Divider>Recent posts from the relay admin</Divider>
<ProfileFeed {url} {pubkey} />
2024-11-01 22:08:27 +00:00
{/if}
</div>
2024-09-23 20:10:15 +00:00
</div>