From 8e7c45aae2c5ece1c3b3a4baab10a2bdc5b6c2ae Mon Sep 17 00:00:00 2001 From: hugo Date: Thu, 12 Feb 2026 12:32:25 +0100 Subject: [PATCH] fix: drafts always unfiltered and visible --- src/renderer/components/Sidebar/Sidebar.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/Sidebar/Sidebar.tsx b/src/renderer/components/Sidebar/Sidebar.tsx index d61edaa..d387c84 100644 --- a/src/renderer/components/Sidebar/Sidebar.tsx +++ b/src/renderer/components/Sidebar/Sidebar.tsx @@ -360,14 +360,15 @@ const PostsList: React.FC = () => { }; // Determine which posts to display - const displayPosts = searchResults ?? filteredPosts ?? posts; - const isFiltered = searchResults !== null || filteredPosts !== null; + // Filters only apply to published/archived posts — drafts are always shown unfiltered + const filteredDisplayPosts = searchResults ?? filteredPosts ?? null; + const isFiltered = filteredDisplayPosts !== null; const hasActiveFilters = searchQuery || selectedYear || selectedTags.length > 0 || selectedCategories.length > 0; const groupedPosts = { - draft: displayPosts.filter(p => p.status === 'draft'), - published: displayPosts.filter(p => p.status === 'published'), - archived: displayPosts.filter(p => p.status === 'archived'), + draft: posts.filter(p => p.status === 'draft'), + published: (filteredDisplayPosts ?? posts).filter(p => p.status === 'published'), + archived: (filteredDisplayPosts ?? posts).filter(p => p.status === 'archived'), }; const clearAllFilters = () => { @@ -436,7 +437,7 @@ const PostsList: React.FC = () => { {hasActiveFilters && (
- {displayPosts.length} result{displayPosts.length !== 1 ? 's' : ''} + {groupedPosts.published.length + groupedPosts.archived.length} result{groupedPosts.published.length + groupedPosts.archived.length !== 1 ? 's' : ''} {searchQuery && ` for "${searchQuery}"`}
)} - {displayPosts.length === 0 && !isFiltered && ( + {posts.length === 0 && !isFiltered && (

No posts yet

)} - {displayPosts.length === 0 && isFiltered && ( + {groupedPosts.published.length === 0 && groupedPosts.archived.length === 0 && isFiltered && (

No matching posts