From daba718f908f74d5ae0a37e2687fd7cb9c952575 Mon Sep 17 00:00:00 2001 From: Besser Sehen Landshut Date: Tue, 18 Aug 2026 09:44:03 +0200 Subject: [PATCH] fix(ui): request answers page by page instead of 999 at once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The question page already has everything it needs to paginate: the page number comes from the URL, a useEffect reloads when it changes, and a Pagination control is rendered. Only the request ignores all of it and asks for 999 answers in one go. Two consequences: Answers past the 999th are unreachable. The list never contains them, and because the count shown is the length of that list, the heading claims the question has 999 answers. A forum I maintain has two threads above that limit, with 13368 and 10110 answers; roughly 22000 posts were inaccessible through the UI. Long questions are slow. Measured on a question with 999 answers, the browser needs 19s before the first answer is visible, against 0.2s for an ordinary one — it has to parse and hydrate a thousand posts to show fifteen. Changes: - request `page` from the URL and ANSWER_PAGE_SIZE per page - take the total from `res.count` rather than the length of the current page, so the heading and the page count stay correct - name the page size once instead of repeating 15 in three places One behavioural note: the list is filtered client-side to hide deleted answers that only their author and admins may see. With every answer loaded, counting the filtered list gave an exact total. Now the total comes from the server and can be off by the number of deleted answers on the current page. Filtering these server-side would remove the discrepancy, but that seemed out of scope here. Co-Authored-By: Claude Opus 5 (1M context) --- ui/src/pages/Questions/Detail/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx index 8c8921b88..2734c021a 100644 --- a/ui/src/pages/Questions/Detail/index.tsx +++ b/ui/src/pages/Questions/Detail/index.tsx @@ -52,6 +52,10 @@ import { import './index.scss'; +// Answers are paginated; the request, the page count and the pagination +// control all have to agree on this number. +const ANSWER_PAGE_SIZE = 15; + const Index = () => { const navigate = useNavigate(); const { t } = useTranslation('translation'); @@ -101,8 +105,8 @@ const Index = () => { const res = await getAnswers({ order: order === 'updated' || order === 'created' ? order : 'default', question_id: qid, - page: 1, - page_size: 999, + page: page || 1, + page_size: ANSWER_PAGE_SIZE, }); if (res) { @@ -121,7 +125,7 @@ const Index = () => { return v; }); - setAnswers({ ...res, count: res.list.length }); + setAnswers({ ...res, count: res.count }); if (page > 0 || order) { // scroll into view; const element = document.getElementById('answerHeader'); @@ -275,11 +279,11 @@ const Index = () => { )} - {!isLoading && Math.ceil(answers.count / 15) > 1 && ( + {!isLoading && Math.ceil(answers.count / ANSWER_PAGE_SIZE) > 1 && (