mirror of
https://github.com/hoornet/vega.git
synced 2026-05-07 20:59:12 -07:00
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:
@@ -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];
|
||||
}
|
||||
Reference in New Issue
Block a user