From fecebc24a8b522879520f7c14eec547caf8e3796 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 23 Nov 2023 08:34:43 +0800 Subject: [PATCH] Fix missing posts due to GC Hidden/collapsed comments are not mounted so they got accidentally GC-ed --- src/app.jsx | 9 +++++++-- src/pages/status.jsx | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app.jsx b/src/app.jsx index 44d937ad..f0f89fa5 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -72,7 +72,9 @@ window.__STATES_STATS__ = () => { const { statuses } = states; const unmountedPosts = []; for (const key in statuses) { - const $post = document.querySelector(`[data-state-post-id="${key}"]`); + const $post = document.querySelector( + `[data-state-post-id="${key}"], [data-state-post-ids~="${key}"]`, + ); if (!$post) { unmountedPosts.push(key); } @@ -89,8 +91,11 @@ setInterval(() => { let keysCount = 0; const { instance } = api(); for (const key in statuses) { + if (!window.__IDLE__) break; try { - const $post = document.querySelector(`[data-state-post-id~="${key}"]`); + const $post = document.querySelector( + `[data-state-post-id="${key}"], [data-state-post-ids~="${key}"]`, + ); const postInNotifications = notifications.some( (n) => key === statusKey(n.status?.id, instance), ); diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 22ffdb83..86cecbec 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -1137,6 +1137,10 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { disabled={uiState === 'loading'} onClick={() => setLimit((l) => l + LIMIT)} style={{ marginBlockEnd: '6em' }} + data-state-post-ids={statuses + .slice(limit) + .map((s) => statusKey(s.id, instance)) + .join(' ')} >
{/* show avatars for first 5 statuses */}