diff --git a/src/app/forum/page.tsx b/src/app/forum/page.tsx index bc41473..f0577b0 100644 --- a/src/app/forum/page.tsx +++ b/src/app/forum/page.tsx @@ -232,27 +232,25 @@ export default function ForumIndexPage() { .catch(() => setFollowingLoading(false)); }, [feedMode, currentUserId]); - // Load threads when search/category/sort changes + // Always load threads on mount + whenever search/category/sort changes. + // (Prior version only loaded in "search mode" which left the forum + // index blank by default, hiding all threads in the DB.) const isSearchMode = debouncedSearch.trim() !== '' || selectedCategory !== '' || sort !== 'newest'; useEffect(() => { - if (!isSearchMode) { - setThreads([]); - return; - } setThreadsLoading(true); const params = new URLSearchParams({ limit: '30', sort }); if (debouncedSearch.trim()) params.set('search', debouncedSearch.trim()); if (selectedCategory) params.set('category_id', selectedCategory); fetch(`/api/forum/threads?${params.toString()}`) - .then(r => r.json()) - .then(d => { + .then((r) => r.json()) + .then((d) => { setThreads(d.threads || []); setThreadsLoading(false); }) .catch(() => setThreadsLoading(false)); - }, [debouncedSearch, selectedCategory, sort, isSearchMode]); + }, [debouncedSearch, selectedCategory, sort]); const sortOptions: { value: SortOption; label: string }[] = [ { value: 'newest', label: 'Newest' }, @@ -527,6 +525,39 @@ export default function ForumIndexPage() { )} + {/* Recent Threads — newest first across all categories */} + {!loading && !error && threads.length > 0 && ( +
+ by e.stopPropagation()}>{thread.author_name} + {thread.forum_categories && ( + <> · {thread.forum_categories.name}> + )} + {' · '}{timeAgo(thread.last_reply_at || thread.created_at)} +
+