getReplies method

Future<QueryRepliesResponse> getReplies (
  1. String parentId,
  2. PaginationParams options
)

List the message replies for a parent message

Implementation

Future<QueryRepliesResponse> getReplies(
  String parentId,
  PaginationParams options,
) async {
  final cachedReplies = await _client.offlineStorage?.getReplies(parentId);
  if (cachedReplies != null && cachedReplies.isNotEmpty) {
    state?.updateThreadInfo(parentId, cachedReplies);
  }

  final response = await _client.get('/messages/$parentId/replies',
      queryParameters: options.toJson());

  final repliesResponse = _client.decode<QueryRepliesResponse>(
    response.data,
    QueryRepliesResponse.fromJson,
  );

  state?.updateThreadInfo(parentId, repliesResponse.messages);

  return repliesResponse;
}