appendListResult method

void appendListResult(
  1. String queryKey,
  2. List<String> ids, {
  3. String? entityType,
  4. int? total,
  5. String? nextCursor,
  6. bool hasNextPage = false,
})

Implementation

void appendListResult(
  String queryKey,
  List<String> ids, {
  String? entityType,
  int? total,
  String? nextCursor,
  bool hasNextPage = false,
}) {
  _write(() {
    if (entityType != null) _listTypes[queryKey] = entityType;
    final prev = _lists[queryKey] ?? ListState.empty;
    final merged = [
      ...prev.ids,
      ...ids.where((id) => !prev.ids.contains(id)),
    ];
    _lists[queryKey] = prev.copyWith(
      ids: List.unmodifiable(merged),
      total: total ?? prev.total,
      nextCursor: nextCursor,
      hasNextPage: hasNextPage,
      isFetching: false,
      isFetchingMore: false,
      lastFetched: DateTime.now(),
      stale: false,
      clearError: true,
    );
    _notifyList(queryKey);
  });
}