flotilla/src/routes/spaces/[nrelay]/threads/+page.svelte

58 lines
1.8 KiB
Svelte
Raw Normal View History

2024-09-23 20:10:15 +00:00
<script lang="ts">
import {page} from "$app/stores"
2024-09-23 20:58:01 +00:00
import {sortBy} from "@welshman/lib"
2024-09-23 20:10:15 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Spinner from "@lib/components/Spinner.svelte"
import ThreadItem from "@app/components/ThreadItem.svelte"
2024-09-23 20:10:15 +00:00
import ThreadCreate from "@app/components/ThreadCreate.svelte"
import {pushModal} from "@app/modal"
import {threadsByUrl, decodeNRelay} from "@app/state"
const url = decodeNRelay($page.params.nrelay)
const createThread = () => pushModal(ThreadCreate, {url})
let loading = true
$: threads = sortBy(thread => -thread.root.created_at, $threadsByUrl.get(url) || [])
setTimeout(() => {
loading = false
}, 3000)
</script>
<div class="relative flex h-screen flex-col">
<div class="relative z-feature mx-2 rounded-xl pt-4">
<div
class="flex min-h-12 items-center justify-between gap-4 rounded-xl bg-base-100 px-4 shadow-xl">
<div class="flex items-center gap-2">
<Icon icon="notes-minimalistic" />
<strong>Threads</strong>
</div>
</div>
</div>
2024-09-23 20:58:01 +00:00
<div class="flex flex-grow flex-col gap-2 overflow-auto p-2">
{#each threads as { root, replies } (root.id)}
<ThreadItem {root} {replies} />
2024-09-23 20:10:15 +00:00
{/each}
<p class="flex h-10 items-center justify-center py-20">
<Spinner {loading}>
{#if loading}
Looking for threads...
{:else if threads.length === 0}
No threads found.
{/if}
</Spinner>
</p>
</div>
2024-09-23 20:58:01 +00:00
<Button
class="tooltip tooltip-left fixed bottom-4 right-4 p-1"
data-tip="Create an Event"
on:click={createThread}>
<div class="btn btn-circle btn-primary flex h-12 w-12 items-center justify-center">
2024-09-23 20:10:15 +00:00
<Icon icon="add-square" />
</div>
</Button>
</div>