fetchPinnedMessages method

Future<List<ChatMessage>> fetchPinnedMessages({
  1. required String conversationId,
})

Gets the list of pinned messages from the server.

Param conversationId The conversation ID. Returns The list of pinned messages. Throws A description of the exception. See ChatError.

Implementation

Future<List<ChatMessage>> fetchPinnedMessages(
    {required String conversationId}) async {
  try {
    Map map = {'convId': conversationId};
    Map result = await platform_interface.Client.instance.chatManager.callNativeMethod(
      ChatMethodKeys.fetchPinnedMessages,
      map,
    );
    ChatError.hasErrorFromResult(result);
    List<ChatMessage> messages = [];
    List list = result[ChatMethodKeys.fetchPinnedMessages];
    for (var element in list) {
      messages.add(ChatMessage.fromJson(element));
    }
    return messages;
  } catch (e) {
    rethrow;
  }
}