Simplify notification badges, improve performance (#57)

Co-authored-by: Jon Staab <shtaab@gmail.com>
This commit is contained in:
hodlbod
2026-02-09 11:44:32 -08:00
committed by GitHub
parent 8f73fb85e9
commit c4f2f55617
19 changed files with 91 additions and 258 deletions
+4 -3
View File
@@ -1,17 +1,18 @@
<script lang="ts">
import {onMount} from "svelte"
import {max, formatTimestampRelative} from "@welshman/lib"
import {max, gt, formatTimestampRelative} from "@welshman/lib"
import {COMMENT} from "@welshman/util"
import {load} from "@welshman/net"
import {deriveArray, deriveEventsById} from "@welshman/store"
import type {TrustedEvent} from "@welshman/util"
import {repository} from "@welshman/app"
import {notifications} from "@app/util/notifications"
import {deriveChecked} from "@app/util/notifications"
import Reply from "@assets/icons/reply-2.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
const {url, path, event}: {url: string; path: string; event: TrustedEvent} = $props()
const checked = deriveChecked(path)
const filters = [{kinds: [COMMENT], "#E": [event.id]}]
const replies = deriveArray(deriveEventsById({repository, filters}))
const lastActive = $derived(max([...$replies, event].map(e => e.created_at)))
@@ -26,7 +27,7 @@
<span>{$replies.length} {$replies.length === 1 ? "reply" : "replies"}</span>
</div>
<div class="btn btn-neutral btn-xs relative hidden rounded-full sm:flex">
{#if $notifications.has(path)}
{#if gt(lastActive, $checked)}
<div class="h-2 w-2 rounded-full bg-primary"></div>
{/if}
Active {formatTimestampRelative(lastActive)}