2024-08-14 21:52:00 +00:00
|
|
|
<script lang="ts">
|
2024-08-16 17:50:38 +00:00
|
|
|
import {onMount} from "svelte"
|
|
|
|
|
import Masonry from "svelte-bricks"
|
2024-09-11 18:09:25 +00:00
|
|
|
import {relaySearch} from "@welshman/app"
|
2024-09-11 22:21:25 +00:00
|
|
|
import {createScroller} from "@lib/html"
|
2024-08-16 17:50:38 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
2024-10-09 23:11:23 +00:00
|
|
|
import PageHeader from "@lib/components/PageHeader.svelte"
|
2024-10-09 21:19:27 +00:00
|
|
|
import RelayName from "@app/components/RelayName.svelte"
|
|
|
|
|
import RelayDescription from "@app/components/RelayDescription.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
import SpaceCheck from "@app/components/SpaceCheck.svelte"
|
2024-10-09 16:44:41 +00:00
|
|
|
import {userMembership, discoverRelays, getMembershipUrls} from "@app/state"
|
2024-10-10 21:33:50 +00:00
|
|
|
import {pushModal} from '@app/modal'
|
|
|
|
|
|
|
|
|
|
const openSpace = (url: string) => pushModal(SpaceCheck, {url})
|
2024-08-15 19:08:07 +00:00
|
|
|
|
2024-08-14 21:52:00 +00:00
|
|
|
let term = ""
|
2024-09-11 18:33:50 +00:00
|
|
|
let limit = 20
|
2024-10-01 21:55:33 +00:00
|
|
|
let element: Element
|
2024-09-11 18:33:50 +00:00
|
|
|
|
|
|
|
|
$: relays = $relaySearch.searchOptions(term).slice(0, limit)
|
2024-08-23 20:33:36 +00:00
|
|
|
|
2024-08-14 21:52:00 +00:00
|
|
|
onMount(() => {
|
2024-09-11 17:48:34 +00:00
|
|
|
const sub = discoverRelays()
|
2024-10-01 21:55:33 +00:00
|
|
|
const scroller = createScroller({
|
2024-10-11 00:09:01 +00:00
|
|
|
element: element.closest(".overflow-auto")!,
|
2024-10-01 21:55:33 +00:00
|
|
|
onScroll: () => {
|
|
|
|
|
limit += 20
|
|
|
|
|
},
|
|
|
|
|
})
|
2024-09-11 17:48:34 +00:00
|
|
|
|
2024-09-11 18:33:50 +00:00
|
|
|
return () => {
|
|
|
|
|
sub.close()
|
|
|
|
|
scroller.stop()
|
|
|
|
|
}
|
2024-08-14 21:52:00 +00:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-10-01 21:55:33 +00:00
|
|
|
<div class="content column gap-4" bind:this={element}>
|
2024-10-09 23:11:23 +00:00
|
|
|
<PageHeader>
|
|
|
|
|
<div slot="title">Discover Spaces</div>
|
|
|
|
|
<div slot="info">Find communities all across the nostr network</div>
|
|
|
|
|
</PageHeader>
|
2024-08-16 17:50:38 +00:00
|
|
|
<label class="input input-bordered flex w-full items-center gap-2">
|
2024-08-14 23:25:36 +00:00
|
|
|
<Icon icon="magnifer" />
|
|
|
|
|
<input bind:value={term} class="grow" type="text" placeholder="Search for spaces..." />
|
|
|
|
|
</label>
|
2024-08-16 17:50:38 +00:00
|
|
|
<Masonry
|
|
|
|
|
animate={false}
|
2024-09-11 17:48:34 +00:00
|
|
|
items={relays}
|
2024-08-16 17:50:38 +00:00
|
|
|
minColWidth={250}
|
|
|
|
|
maxColWidth={800}
|
|
|
|
|
gap={16}
|
2024-09-11 17:48:34 +00:00
|
|
|
idKey="url"
|
|
|
|
|
let:item={relay}>
|
2024-10-10 21:33:50 +00:00
|
|
|
<Button
|
2024-10-11 00:09:01 +00:00
|
|
|
class="card2 bg-alt text-left flex flex-col gap-2 shadow-xl transition-all hover:shadow-2xl hover:brightness-[1.1]"
|
2024-10-10 21:33:50 +00:00
|
|
|
on:click={() => openSpace(relay.url)}>
|
2024-10-11 00:09:01 +00:00
|
|
|
<div class="flex gap-4">
|
|
|
|
|
<div class="avatar">
|
|
|
|
|
<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}
|
|
|
|
|
</div>
|
2024-08-14 21:52:00 +00:00
|
|
|
</div>
|
2024-10-11 00:09:01 +00:00
|
|
|
{#if getMembershipUrls($userMembership).includes(relay.url)}
|
|
|
|
|
<div class="flex justify-center">
|
|
|
|
|
<div class="relative">
|
|
|
|
|
<div
|
|
|
|
|
class="tooltip absolute -top-[88px] left-5 h-5 w-5 rounded-full bg-primary"
|
|
|
|
|
data-tip="You are already a member of this space.">
|
|
|
|
|
<Icon icon="check-circle" class="scale-110" />
|
|
|
|
|
</div>
|
2024-10-09 16:44:41 +00:00
|
|
|
</div>
|
2024-08-15 19:25:22 +00:00
|
|
|
</div>
|
2024-10-11 00:09:01 +00:00
|
|
|
{/if}
|
|
|
|
|
<div>
|
|
|
|
|
<h2 class="text-xl">
|
|
|
|
|
<RelayName url={relay.url} />
|
|
|
|
|
</h2>
|
|
|
|
|
<p class="text-sm opacity-75">{relay.url}</p>
|
2024-08-15 19:25:22 +00:00
|
|
|
</div>
|
2024-10-09 21:19:27 +00:00
|
|
|
</div>
|
2024-10-11 00:09:01 +00:00
|
|
|
<RelayDescription url={relay.url} class="ml-16" />
|
2024-10-10 21:33:50 +00:00
|
|
|
</Button>
|
2024-08-14 21:52:00 +00:00
|
|
|
</Masonry>
|
|
|
|
|
</div>
|