messages method

Future<Page<DtoChatItem, ChatItemsCursor>> messages(
  1. ChatId id, {
  2. int? first,
  3. ChatItemsCursor? after,
  4. int? last,
  5. ChatItemsCursor? before,
  6. bool onlyAttachments = false,
  7. ChatMessageText? withText,
})

Fetches ChatItems of the Chat with the provided id ordered by their posting time with pagination.

Implementation

Future<Page<DtoChatItem, ChatItemsCursor>> messages(
  ChatId id, {
  int? first,
  ChatItemsCursor? after,
  int? last,
  ChatItemsCursor? before,
  bool onlyAttachments = false,
  ChatMessageText? withText,
}) async {
  Log.debug(
    'messages($id, $first, $after, $last, $before, onlyAttachments: $onlyAttachments)',
    '$runtimeType',
  );

  var query = await _graphQlProvider.chatItems(
    id,
    first: first,
    after: after,
    last: last,
    before: before,
    filter:
        onlyAttachments || withText != null
            ? ChatItemsFilter(
              onlyAttachments: onlyAttachments,
              withText: withText,
            )
            : null,
  );

  return Page(
    RxList(query.chat!.items.edges.map((e) => e.toDto()).toList()),
    query.chat!.items.pageInfo.toModel((c) => ChatItemsCursor(c)),
  );
}