Bump to v0.5.0 — note sharing, reply counts

This commit is contained in:
Jure
2026-03-15 21:49:52 +01:00
parent 5b4f6381da
commit 8ce1d43d2d
10 changed files with 85 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
import { useEffect, useState } from "react";
import { fetchReplyCount } from "../lib/nostr";
const cache = new Map<string, number>();
export function useReplyCount(eventId: string): [number | null, (delta: number) => void] {
const [count, setCount] = useState<number | null>(() => cache.get(eventId) ?? null);
useEffect(() => {
if (cache.has(eventId)) {
setCount(cache.get(eventId)!);
return;
}
fetchReplyCount(eventId).then((n) => {
cache.set(eventId, n);
setCount(n);
});
}, [eventId]);
const adjust = (delta: number) => {
setCount((prev) => {
const next = (prev ?? 0) + delta;
cache.set(eventId, next);
return next;
});
};
return [count, adjust];
}