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

61 lines
1.8 KiB
Svelte
Raw Normal View History

2025-10-06 18:23:19 +00:00
<script lang="ts">
2026-06-24 20:10:06 +00:00
import {onMount} from "svelte"
2025-10-06 18:23:19 +00:00
import {page} from "$app/stores"
import History from "@assets/icons/history.svg?dataurl"
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
2025-10-06 18:23:19 +00:00
import {createScroller} from "@lib/html"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
2025-10-06 18:23:19 +00:00
import PageContent from "@lib/components/PageContent.svelte"
import SpaceBar from "@app/components/SpaceBar.svelte"
import RecentItem from "@app/components/RecentItem.svelte"
2026-06-24 20:10:06 +00:00
import SpaceSearch from "@app/components/SpaceSearch.svelte"
import {decodeRelay} from "@app/relays"
import {deriveRecentActivity} from "@app/recent"
2026-06-24 20:10:06 +00:00
import {pushModal} from "@app/modal"
2025-10-06 18:23:19 +00:00
const url = decodeRelay($page.params.relay!)
const recentActivity = deriveRecentActivity(url)
2025-10-06 18:23:19 +00:00
2026-06-24 20:10:06 +00:00
const openSearch = () => pushModal(SpaceSearch, {url})
2026-02-02 23:36:50 +00:00
let limit = $state(20)
2025-10-06 18:23:19 +00:00
let element: Element | undefined = $state()
onMount(() => {
const scroller = createScroller({
element: element!,
onScroll: () => {
2026-02-02 23:36:50 +00:00
limit += 10
2025-10-06 18:23:19 +00:00
},
})
return () => scroller.stop()
})
</script>
<SpaceBar>
{#snippet leading()}
<Icon icon={History} />
{/snippet}
{#snippet title()}
2025-10-06 18:23:19 +00:00
<strong>Recent Activity</strong>
{/snippet}
{#snippet action()}
2026-06-24 20:10:06 +00:00
<Button class="btn btn-neutral btn-sm btn-square" aria-label="Search" onclick={openSearch}>
<Icon size={4} icon={Magnifier} />
2026-06-24 20:10:06 +00:00
</Button>
{/snippet}
</SpaceBar>
2025-10-06 18:23:19 +00:00
2026-06-22 20:36:57 +00:00
<PageContent class="flex flex-col gap-2 p-2 sm:gap-4 sm:p-4" bind:element>
{#if $recentActivity.length === 0}
<p class="flex flex-col items-center py-20 text-center">No recent activity found!</p>
{:else}
{#each $recentActivity.slice(0, limit) as item (item.event.id)}
<RecentItem {url} {item} />
{/each}
{/if}
</PageContent>