2025-02-06 17:53:50 +00:00
|
|
|
<script lang="ts">
|
2026-08-29 16:48:04 +00:00
|
|
|
import {derived} from "svelte/store"
|
|
|
|
|
import {filter, max, gt, spec, formatTimestampRelative} from "@welshman/lib"
|
|
|
|
|
import {COMMENT} from "@welshman/util"
|
2025-02-06 17:53:50 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2025-09-10 22:26:39 +00:00
|
|
|
import Reply from "@assets/icons/reply-2.svg?dataurl"
|
2025-02-06 17:53:50 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2026-08-29 16:48:04 +00:00
|
|
|
import type {FeedContext} from "@app/feeds"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {deriveChecked} from "@app/notifications"
|
2025-02-06 17:53:50 +00:00
|
|
|
|
2026-08-29 16:48:04 +00:00
|
|
|
const {path, event, context}: {path: string; event: TrustedEvent; context: FeedContext} = $props()
|
2025-02-06 17:53:50 +00:00
|
|
|
|
2026-02-09 19:44:32 +00:00
|
|
|
const checked = deriveChecked(path)
|
2026-08-29 16:48:04 +00:00
|
|
|
const related = context.related(event)
|
|
|
|
|
const replies = derived(related, $related => filter(spec({kind: COMMENT}), $related))
|
2025-02-06 17:53:50 +00:00
|
|
|
const lastActive = $derived(max([...$replies, event].map(e => e.created_at)))
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="flex-inline button button-neutral button-xs gap-1 rounded-full">
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={Reply} />
|
2025-02-06 17:53:50 +00:00
|
|
|
<span>{$replies.length} {$replies.length === 1 ? "reply" : "replies"}</span>
|
|
|
|
|
</div>
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="button button-neutral button-xs relative rounded-full">
|
2026-02-09 19:44:32 +00:00
|
|
|
{#if gt(lastActive, $checked)}
|
2026-06-24 20:56:53 +00:00
|
|
|
<div class="h-2 w-2 rounded-full bg-primary text-primary-content"></div>
|
2025-02-06 17:53:50 +00:00
|
|
|
{/if}
|
|
|
|
|
Active {formatTimestampRelative(lastActive)}
|
|
|
|
|
</div>
|