johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
<script lang="ts">
import type * as getFeed from '#lib/lexicons/dev/knotless/getFeed.ts';
import type { Snippet } from 'svelte';
import { entries } from '#lib/feed.ts';
import { day, weekday } from '#lib/format.ts';
import FeedItem from '#lib/molecules/FeedItem.svelte';
import { zone } from '#lib/zone.svelte.ts';
import Empty from '#lib/molecules/Empty.svelte';
/**
* What happened, a day at a time, as `entries` puts it together. A day can come round again, as what
* an account says it made when need not be the order it came in, so
* each run of one is keyed by where it is. On `owner`'s own page, its
* own lines leave out its picture and name; `empty` says what shows,
* in a box where the lines would be, when nothing does.
*/
let { events, owner, empty }: { events: getFeed.EventView[]; owner?: string; empty?: Snippet } =
$props();
const days = $derived.by(() => {
const out: [string, getFeed.EventView[]][] = [];
for (const e of events) {
const on = day(e.createdAt);
const last = out.at(-1);
if (last && last[0] === on) last[1].push(e);
else out.push([on, [e]]);
}
return out.map(([on, list]) => [on, entries(list)] as const);
});
</script>
{#each days as [, list], d (d)}
<h2 class="feed-day" class:zoneless={!zone.tz}>{weekday(list[0].createdAt)}</h2>
<ul class="feed">
{#each list as x, i (i)}
<FeedItem
entry={x}
own={x.actor.did === owner && !(x.kind === 'starred' && x.actors.length > 1)}
/>
{/each}
</ul>
{:else}
<div class="box feed-empty">
{#if empty}{@render empty()}{:else}<Empty title="Nothing yet"
>Pushes, pulls and issues show up here as they happen, from any account on any PDS.</Empty
>{/if}
</div>
{/each}