2025-02-06 17:53:50 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {onMount} from "svelte"
|
2026-02-09 19:44:32 +00:00
|
|
|
import {max, gt, formatTimestampRelative} from "@welshman/lib"
|
2025-02-06 17:53:50 +00:00
|
|
|
import {COMMENT} from "@welshman/util"
|
|
|
|
|
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-07-28 16:16:26 +00:00
|
|
|
import {deriveEvents} from "@app/repository"
|
|
|
|
|
import {network} from "@app/core"
|
|
|
|
|
import {deriveChecked} from "@app/notifications"
|
2025-02-06 17:53:50 +00:00
|
|
|
|
|
|
|
|
const {url, path, event}: {url: string; path: string; event: TrustedEvent} = $props()
|
|
|
|
|
|
2026-02-09 19:44:32 +00:00
|
|
|
const checked = deriveChecked(path)
|
2025-02-06 17:53:50 +00:00
|
|
|
const filters = [{kinds: [COMMENT], "#E": [event.id]}]
|
2026-07-28 16:16:26 +00:00
|
|
|
const replies = deriveEvents(filters)
|
2025-02-06 17:53:50 +00:00
|
|
|
const lastActive = $derived(max([...$replies, event].map(e => e.created_at)))
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
2026-07-28 16:16:26 +00:00
|
|
|
$network.load({relays: [url], filters})
|
2025-02-06 17:53:50 +00:00
|
|
|
})
|
|
|
|
|
</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>
|