mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix: memory leak in ModQueueButtonContent statusMap
This commit is contained in:
@@ -318,6 +318,20 @@ const ModQueueButtonContent = ({ feed, alertThresholdSeconds, boardIdentifier, i
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Clean up stale entries when comments leave the feed to prevent memory leaks
|
||||||
|
const feedCids = useMemo(() => new Set(feed.map((item) => item.cid)), [feed]);
|
||||||
|
useEffect(() => {
|
||||||
|
setStatusMap((prev) => {
|
||||||
|
const staleKeys = [...prev.keys()].filter((cid) => !feedCids.has(cid));
|
||||||
|
if (staleKeys.length === 0) return prev;
|
||||||
|
const next = new Map(prev);
|
||||||
|
for (const key of staleKeys) {
|
||||||
|
next.delete(key);
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, [feedCids]);
|
||||||
|
|
||||||
const { normalCount, urgentCount } = useMemo(() => {
|
const { normalCount, urgentCount } = useMemo(() => {
|
||||||
let normal = 0;
|
let normal = 0;
|
||||||
let urgent = 0;
|
let urgent = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user