From 096bc6958470c6b77a8450d2294ce3d4b5350312 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 30 Dec 2023 21:03:10 +0800 Subject: [PATCH] Fix child replies accidentally got GC-ed --- src/pages/status.jsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 39e5fe00..e52ee7e0 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -901,6 +901,19 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { return STATUS_URL_REGEX.test(states.prevLocation?.pathname); }, [sKey]); + const moreStatusesKeys = useMemo(() => { + if (!showMore) return []; + const ids = []; + function getIDs(status) { + ids.push(status.id); + if (status.replies) { + status.replies.forEach(getIDs); + } + } + statuses.slice(limit).forEach(getIDs); + return ids.map((id) => statusKey(id, instance)); + }, [showMore, statuses, limit, instance]); + return (
setLimit((l) => l + LIMIT)} style={{ marginBlockEnd: '6em' }} - data-state-post-ids={statuses - .slice(limit) - .map((s) => statusKey(s.id, instance)) - .join(' ')} + data-state-post-ids={moreStatusesKeys.join(' ')} >
{/* show avatars for first 5 statuses */}