fix in-thread search. (#294)

This commit is contained in:
Jojo Feng
2023-11-02 14:51:46 -07:00
committed by GitHub
parent 3ee60e1a44
commit 939d55ef0d
3 changed files with 5 additions and 1 deletions

View File

@ -113,6 +113,8 @@ class CommentsCubit extends Cubit<CommentsState> {
state.copyWith( state.copyWith(
status: CommentsStatus.inProgress, status: CommentsStatus.inProgress,
comments: <Comment>[], comments: <Comment>[],
matchedComments: <int>[],
inThreadSearchQuery: '',
currentPage: 0, currentPage: 0,
), ),
); );

View File

@ -141,6 +141,7 @@ class _InThreadSearchViewState extends State<_InThreadSearchView> {
children: <Widget>[ children: <Widget>[
for (final int i in state.matchedComments) for (final int i in state.matchedComments)
CommentTile( CommentTile(
index: i,
comment: state.comments.elementAt(i), comment: state.comments.elementAt(i),
fetchMode: FetchMode.lazy, fetchMode: FetchMode.lazy,
actionable: false, actionable: false,

View File

@ -359,7 +359,8 @@ class CommentTile extends StatelessWidget {
final CollapseState collapseState = context.read<CollapseCubit>().state; final CollapseState collapseState = context.read<CollapseCubit>().state;
final CommentsState? commentsState = final CommentsState? commentsState =
context.tryRead<CommentsCubit>()?.state; context.tryRead<CommentsCubit>()?.state;
return fetchMode == FetchMode.lazy && return actionable &&
fetchMode == FetchMode.lazy &&
comment.kids.isNotEmpty && comment.kids.isNotEmpty &&
collapseState.collapsed == false && collapseState.collapsed == false &&
commentsState?.commentIds.contains(comment.kids.first) == false && commentsState?.commentIds.contains(comment.kids.first) == false &&