onQueryMoreComments method

void onQueryMoreComments(
  1. PaginationResult<CommentData> result, {
  2. Filter<Object>? filter,
  3. CommentsSort? sort,
})

Handles the result of a query for more comments.

Implementation

void onQueryMoreComments(
  PaginationResult<CommentData> result, {
  Filter? filter,
  CommentsSort? sort,
}) {
  _queryConfig = (filter: filter, sort: sort);

  // Merge the new comments with the existing ones (keeping the sort order)
  final updatedComments = state.comments.merge(
    result.items,
    key: (it) => it.id,
    compare: commentSort.compare,
  );

  state = state.copyWith(
    comments: updatedComments,
    pagination: result.pagination,
  );
}