From 939d55ef0da9938c27e8fe44d515d473c66c4cfa Mon Sep 17 00:00:00 2001 From: Jojo Feng Date: Thu, 2 Nov 2023 14:51:46 -0700 Subject: [PATCH] fix in-thread search. (#294) --- lib/cubits/comments/comments_cubit.dart | 2 ++ lib/screens/item/widgets/in_thread_search_icon_button.dart | 1 + lib/screens/widgets/comment_tile.dart | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cubits/comments/comments_cubit.dart b/lib/cubits/comments/comments_cubit.dart index 14e1b6b..a249c47 100644 --- a/lib/cubits/comments/comments_cubit.dart +++ b/lib/cubits/comments/comments_cubit.dart @@ -113,6 +113,8 @@ class CommentsCubit extends Cubit { state.copyWith( status: CommentsStatus.inProgress, comments: [], + matchedComments: [], + inThreadSearchQuery: '', currentPage: 0, ), ); diff --git a/lib/screens/item/widgets/in_thread_search_icon_button.dart b/lib/screens/item/widgets/in_thread_search_icon_button.dart index 41bcff0..3dfdd70 100644 --- a/lib/screens/item/widgets/in_thread_search_icon_button.dart +++ b/lib/screens/item/widgets/in_thread_search_icon_button.dart @@ -141,6 +141,7 @@ class _InThreadSearchViewState extends State<_InThreadSearchView> { children: [ for (final int i in state.matchedComments) CommentTile( + index: i, comment: state.comments.elementAt(i), fetchMode: FetchMode.lazy, actionable: false, diff --git a/lib/screens/widgets/comment_tile.dart b/lib/screens/widgets/comment_tile.dart index 1267106..6970f8a 100644 --- a/lib/screens/widgets/comment_tile.dart +++ b/lib/screens/widgets/comment_tile.dart @@ -359,7 +359,8 @@ class CommentTile extends StatelessWidget { final CollapseState collapseState = context.read().state; final CommentsState? commentsState = context.tryRead()?.state; - return fetchMode == FetchMode.lazy && + return actionable && + fetchMode == FetchMode.lazy && comment.kids.isNotEmpty && collapseState.collapsed == false && commentsState?.commentIds.contains(comment.kids.first) == false &&