fetchConversationListFromServer method

  1. @Deprecated('Use [fetchConversationsByOptions] instead')
Future<List<EMConversation>> fetchConversationListFromServer({
  1. int pageNum = 1,
  2. int pageSize = 20,
})

~english Gets the list of conversations from the server.

Param pageNum The current page number.

Param pageSize The number of conversations to get on each page.

Return The conversation list of the current user.

Throws A description of the exception. See EMError. ~end

~chinese 获取服务器会话列表。

Param pageNum 当前页码。

Param pageSize 每页期望返回的会话数量。

Return 当前用户的会话列表。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end

Implementation

@Deprecated('Use [fetchConversationsByOptions] instead')

/// ~english
/// Gets the list of conversations from the server.
///
/// Param [pageNum] The current page number.
///
/// Param [pageSize] The number of conversations to get on each page.
///
/// **Return** The conversation list of the current user.
///
/// **Throws** A description of the exception. See [EMError].
/// ~end
///
/// ~chinese
/// 获取服务器会话列表。
///
/// Param [pageNum] 当前页码。
///
/// Param [pageSize] 每页期望返回的会话数量。
///
/// **Return** 当前用户的会话列表。
///
/// **Throws**  如果有异常会在这里抛出,包含错误码和错误描述,详见 [EMError]。
/// ~end
Future<List<EMConversation>> fetchConversationListFromServer({
  int pageNum = 1,
  int pageSize = 20,
}) async {
  Map request = {
    "pageNum": pageNum,
    "pageSize": pageSize,
  };
  Map result = await ChatChannel.invokeMethod(
    ChatMethodKeys.fetchConversationsFromServerWithPage,
    request,
  );
  try {
    EMError.hasErrorFromResult(result);
    List<EMConversation> conversationList = [];
    result[ChatMethodKeys.fetchConversationsFromServerWithPage]
        ?.forEach((element) {
      conversationList.add(EMConversation.fromJson(element));
    });
    return conversationList;
  } on EMError catch (e) {
    throw e;
  }
}