From a2c8a5885550b7e2e0627f91408cccadb7a8bbfa Mon Sep 17 00:00:00 2001 From: Bretton <36870434+BrettM86@users.noreply.github.com> Date: Mon, 20 Jul 2026 01:33:23 -0700 Subject: [PATCH] fix(post-detail): show the empty state when every comment is filtered out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comments header rendered the post's server-side commentCount ("1 Comment") above a completely empty list when the only comments were hidden from the viewer (e.g. a blocked author — the appview filters the comments but the post stats still count them). When the thread has loaded successfully and nothing is renderable, render the "No comments yet" empty state instead. The stats themselves still overcount when only SOME comments are filtered — making commentCount viewer-aware is backend work (appview post stats), tracked in the QA log. Verified on emulator: post 3mqr5vmmp3322 (single comment by test-aggregator) shows the empty state while the author is blocked and the "1 Comment" header again after unblocking. Co-Authored-By: Claude Fable 5 --- lib/screens/home/post_detail_screen.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/screens/home/post_detail_screen.dart b/lib/screens/home/post_detail_screen.dart index eb3968b..d62f631 100644 --- a/lib/screens/home/post_detail_screen.dart +++ b/lib/screens/home/post_detail_screen.dart @@ -898,11 +898,26 @@ class _PostDetailScreenState extends State { color: AppColors.border, ), - // Comments header with sort dropdown + // Comments header with sort dropdown. + // The server-side commentCount includes + // comments the viewer never sees (deleted, + // blocked, filtered). When the thread + // loaded successfully but nothing is + // renderable, show the empty state instead + // of a count over an empty list. CommentsHeader( key: _commentsHeaderKey, commentCount: - widget.post.post.stats.commentCount, + (!isLoading && + error == null && + comments.isEmpty && + !commentsProvider.hasMore) + ? 0 + : widget + .post + .post + .stats + .commentCount, currentSort: commentsProvider.sort, onSortChanged: _onSortChanged, ), -- 2.51.2