getReplies method
Future<QueryRepliesResponse>
getReplies(
- String parentId, {
- PaginationParams? options,
- bool preferOffline = false,
List the message replies for a parent message.
Set preferOffline
to true to avoid the api call if the data is already
in the offline storage.
Implementation
Future<QueryRepliesResponse> getReplies(
String parentId, {
PaginationParams? options,
bool preferOffline = false,
}) async {
final cachedReplies = await _client.chatPersistenceClient?.getReplies(
parentId,
options: options,
);
if (cachedReplies != null && cachedReplies.isNotEmpty) {
state?.updateThreadInfo(parentId, cachedReplies);
if (preferOffline) {
return QueryRepliesResponse()..messages = cachedReplies;
}
}
final repliesResponse = await _client.getReplies(
parentId,
options: options,
);
state?.updateThreadInfo(parentId, repliesResponse.messages);
return repliesResponse;
}