2026-09-08 22:47:51 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import Inbox from "@assets/icons/inbox.svg?dataurl"
|
|
|
|
|
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
|
|
|
|
import ChatRound from "@assets/icons/chat-round.svg?dataurl"
|
|
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Link from "@lib/components/Link.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-09-08 23:30:23 +00:00
|
|
|
import HomeSection from "@app/components/HomeSection.svelte"
|
2026-09-08 22:47:51 +00:00
|
|
|
import HomeInboxItem from "@app/components/HomeInboxItem.svelte"
|
2026-09-08 23:30:23 +00:00
|
|
|
import RelayIcon from "@app/components/RelayIcon.svelte"
|
2026-09-08 22:47:51 +00:00
|
|
|
import RelayName from "@app/components/RelayName.svelte"
|
|
|
|
|
import {displayContentCount} from "@app/content"
|
|
|
|
|
import {inboxConversations, inboxSpaceContent} from "@app/inbox"
|
|
|
|
|
import {navigate} from "@app/modal"
|
|
|
|
|
import {setChecked} from "@app/notifications"
|
|
|
|
|
import {makeSpacePath} from "@app/routes"
|
|
|
|
|
|
|
|
|
|
const conversations = $derived($inboxConversations.slice(0, 8))
|
|
|
|
|
|
|
|
|
|
const hasUnread = $derived(
|
|
|
|
|
$inboxConversations.some(conversation => conversation.unread) || $inboxSpaceContent.length > 0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const displayContent = (countsByKind: Map<number, number>) =>
|
|
|
|
|
[...countsByKind].map(([kind, count]) => displayContentCount(kind, count)).join(" · ")
|
|
|
|
|
|
|
|
|
|
const markAllRead = () => setChecked("*")
|
|
|
|
|
|
|
|
|
|
const startChat = () => navigate("/chat")
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-09-08 23:30:23 +00:00
|
|
|
<HomeSection title="Inbox" icon={Inbox}>
|
|
|
|
|
{#snippet action()}
|
2026-09-08 22:47:51 +00:00
|
|
|
{#if hasUnread}
|
|
|
|
|
<Button class="button button-neutral button-xs" onclick={markAllRead}>Mark all read</Button>
|
|
|
|
|
{/if}
|
2026-09-08 23:30:23 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#if conversations.length === 0 && $inboxSpaceContent.length === 0}
|
|
|
|
|
<div class="flex flex-col items-center gap-3 px-4 pb-8 text-center">
|
2026-09-08 22:47:51 +00:00
|
|
|
<p class="font-medium">Nothing in your inbox yet</p>
|
|
|
|
|
<p class="max-w-md text-sm opacity-75">
|
|
|
|
|
Rooms and spaces you belong to report their activity here — messages, threads, classifieds,
|
|
|
|
|
events and polls.
|
|
|
|
|
</p>
|
|
|
|
|
<div class="flex flex-wrap justify-center gap-2">
|
|
|
|
|
<Link href="/spaces" class="button button-primary button-sm">
|
|
|
|
|
<Icon icon={AddCircle} size={4} />
|
|
|
|
|
Add a space
|
|
|
|
|
</Link>
|
|
|
|
|
<Button class="button button-neutral button-sm" onclick={startChat}>
|
|
|
|
|
<Icon icon={ChatRound} size={4} />
|
|
|
|
|
Start a conversation
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{:else}
|
2026-09-08 23:30:23 +00:00
|
|
|
<div class="flex flex-col divide-y divide-line border-t border-line">
|
2026-09-08 22:47:51 +00:00
|
|
|
{#each conversations as conversation (conversation.path)}
|
|
|
|
|
<HomeInboxItem {conversation} />
|
|
|
|
|
{/each}
|
2026-09-08 23:30:23 +00:00
|
|
|
{#each $inboxSpaceContent as { url, countsByKind } (url)}
|
|
|
|
|
<Link
|
|
|
|
|
href={makeSpacePath(url)}
|
|
|
|
|
class="flex items-center gap-3 px-4 py-3 text-sm hover:bg-surface-more">
|
|
|
|
|
<RelayIcon {url} size={6} class="shrink-0" />
|
|
|
|
|
<strong class="truncate"><RelayName {url} /></strong>
|
|
|
|
|
<span class="truncate opacity-75">{displayContent(countsByKind)}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
{/each}
|
2026-09-08 22:47:51 +00:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2026-09-08 23:30:23 +00:00
|
|
|
</HomeSection>
|