From da74850ac32142093aabe0022823c5e547d75ac5 Mon Sep 17 00:00:00 2001 From: Milamber ASF Date: Fri, 26 Jun 2026 17:40:57 +0300 Subject: [PATCH] fix(frontend): sort question list by expiration date, closed at end (#32) The "Recent activity" tab previously preserved the backend's updated_at DESC insertion order, with no distinction between open and closed questions. This made it hard to spot which open votes still need attention. New sort order for the Recent tab: - Open questions first, sorted by closes_at ASC (most urgent at the top) - Closed / withdrawn questions at the bottom, sorted by closes_at DESC (most recently expired first) The "Awaiting your response" tab was already sorted by closes_at ASC and is unchanged. Closes #32 Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_015qQoQHpb4kR81SSzc8y6Dv --- frontend/src/components/QuestionList.svelte | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/QuestionList.svelte b/frontend/src/components/QuestionList.svelte index 38a3d39..b6300c0 100644 --- a/frontend/src/components/QuestionList.svelte +++ b/frontend/src/components/QuestionList.svelte @@ -115,12 +115,18 @@ // "Recent activity": every question (open or closed) updated in the // past 14 days, as served by the backend's `recent` array. Project- - // scoped per `inRecentScope`; the backend already orders by - // updated_at DESC, so we preserve that order rather than re-sorting - // by created_at. + // scoped per `inRecentScope`. Sorted: open questions first (soonest + // to expire), then closed/withdrawn (most recently expired last). $: recent = allRecent .filter(inRecentScope) - .filter((q) => matchesFilter(q, filter)); + .filter((q) => matchesFilter(q, filter)) + .sort((a, b) => { + const aOpen = a.status === "open"; + const bOpen = b.status === "open"; + if (aOpen !== bOpen) return aOpen ? -1 : 1; + if (aOpen) return Date.parse(a.closes_at) - Date.parse(b.closes_at); + return Date.parse(b.closes_at) - Date.parse(a.closes_at); + }); onMount(load);