flotilla/src/app/components/ThreadItem.svelte

41 lines
1.4 KiB
Svelte
Raw Normal View History

2024-09-23 20:10:15 +00:00
<script lang="ts">
2024-10-23 23:16:28 +00:00
import {max} from "@welshman/lib"
2024-10-23 21:20:24 +00:00
import {formatTimestamp, formatTimestampRelative} from "@welshman/app"
import {deriveEvents} from "@welshman/store"
import {repository} from "@welshman/app"
import Icon from "@lib/components/Icon.svelte"
import Link from "@lib/components/Link.svelte"
2024-09-24 21:12:38 +00:00
import Content from "@app/components/Content.svelte"
2024-10-23 21:20:24 +00:00
import Profile from "@app/components/Profile.svelte"
import {makeThreadPath} from "@app/routes"
import {REPLY} from "@app/state"
2024-09-23 20:10:15 +00:00
2024-10-23 21:20:24 +00:00
export let url
2024-10-10 17:00:01 +00:00
export let event
2024-10-23 21:20:24 +00:00
const replies = deriveEvents(repository, {filters: [{kinds: [REPLY], "#E": [event.id]}]})
$: lastActive = max([...$replies, event].map(e => e.created_at))
2024-09-23 20:10:15 +00:00
</script>
2024-10-23 21:20:24 +00:00
<Link class="col-2 card2 bg-alt w-full cursor-pointer" href={makeThreadPath(url, event.id)}>
<div class="flex w-full justify-between gap-2">
<Profile pubkey={event.pubkey} />
<p class="text-sm opacity-75">
{formatTimestamp(event.created_at)}
</p>
</div>
2024-10-23 23:16:28 +00:00
<div class="col-4 w-full pl-12">
2024-10-23 21:20:24 +00:00
<Content {event} />
<div class="row-2 justify-end">
<div class="flex-inline btn btn-neutral btn-xs gap-1 rounded-full">
<Icon icon="reply" />
2024-10-23 23:16:28 +00:00
<span>{$replies.length} {$replies.length === 1 ? "reply" : "replies"}</span>
2024-10-23 21:20:24 +00:00
</div>
<div class="btn btn-neutral btn-xs rounded-full">
Active {formatTimestampRelative(lastActive)}
</div>
2024-09-23 20:10:15 +00:00
</div>
2024-10-23 21:20:24 +00:00
</div>
</Link>