next method

  1. @override
Future<List<GroupChannel>> next()
override

Gets the list of next items.

Implementation

@override
Future<List<GroupChannel>> next() async {
  sbLog.i(StackTrace.current);

  if (isLoading) throw QueryInProgressException();
  if (!hasNext) return [];

  isLoading = true;

  final options = <ChannelListQueryIncludeOption>[
    if (includeFrozen) ChannelListQueryIncludeOption.includeFrozen,
    if (includeEmpty) ChannelListQueryIncludeOption.includeEmpty,
    if (includeMetaData) ChannelListQueryIncludeOption.includeMetadata,
    ChannelListQueryIncludeOption.includeMember,
    ChannelListQueryIncludeOption.includeReadReceipt,
    ChannelListQueryIncludeOption.includeDeliveryReceipt,
  ];

  final filter = GroupChannelFilter()
    ..customTypeStartsWith = customTypeStartsWithFilter
    ..customTypes = customTypesFilter
    ..nameContains = channelNameContainsFilter
    ..superMode = superChannelFilter
    ..publicMembershipFilter = membershipFilter
    ..metadataOrderKey = metaDataOrderKeyFilter
    ..metaDataKey = metaDataKey
    ..metaDataValues = metaDataValues
    ..metaDataValueStartsWithFilter = metaDataValueStartsWith
    ..publicMode = PublicChannelFilter.public;

  final res =
      await chat.apiClient.send<ChannelListQueryResponse<GroupChannel>>(
    PublicGroupChannelListRequest(
      chat,
      limit: limit,
      order: order,
      token: token,
      channelUrls: channelUrlsFilter,
      options: options,
      filter: filter,
    ),
  );

  for (final element in res.channels) {
    element.set(chat);
  }

  isLoading = false;
  token = res.next;
  hasNext = res.next != '';
  return res.channels;
}