Remove unused useReactionCount, seed reactions from batch engagement

- Delete useReactionCount hook (replaced by useReactions)
- Remove fetchReactionCount (no longer referenced)
- Seed per-note reaction cache from fetchBatchEngagement in trending
  feed, so emoji pills render instantly without individual fetches
This commit is contained in:
Jure
2026-03-27 18:21:36 +01:00
parent b46d383200
commit 616c3cad27
4 changed files with 9 additions and 36 deletions

View File

@@ -1,29 +0,0 @@
import { useEffect, useState } from "react";
import { fetchReactionCount } from "../lib/nostr";
const cache = new Map<string, number>();
export function useReactionCount(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;
}
fetchReactionCount(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];
}