members method

Future<Page<DtoChatMember, ChatMembersCursor>> members(
  1. ChatId id, {
  2. int? first,
  3. ChatMembersCursor? after,
  4. int? last,
  5. ChatMembersCursor? before,
})

Fetches ChatMembers of the Chat with the provided id ordered by their joining time with pagination.

Implementation

Future<Page<DtoChatMember, ChatMembersCursor>> members(
  ChatId id, {
  int? first,
  ChatMembersCursor? after,
  int? last,
  ChatMembersCursor? before,
}) async {
  Log.debug('members($id, $first, $after, $last, $before)', '$runtimeType');

  final query = await _graphQlProvider.chatMembers(
    id,
    first: first,
    after: after,
    last: last,
    before: before,
  );

  for (var e in query.chat!.members.edges) {
    _userRepo.put(e.node.user.toDto());
  }

  return Page(
    RxList(
      query.chat!.members.edges.map((e) => e.node.toDto(e.cursor)).toList(),
    ),
    query.chat!.members.pageInfo.toModel((c) => ChatMembersCursor(c)),
  );
}