getSessionList static method

Future<List<ConversationInfo>?> getSessionList(
  1. Comparator<ConversationInfo> comparator
)

查询会话列表,支持传入Comparator对会话列表进行排序

Implementation

static Future<List<ConversationInfo>?> getSessionList(
    Comparator<ConversationInfo> comparator) async {
  final _result = await NimCore.instance.messageService.querySessionList();
  if (_result.isSuccess) {
    bool syncUserInfo = (_result.data?.length ?? 0) <= syncLimit;
    List<ConversationInfo>? conversationList =
        await fillSessionInfo(_result.data, fillUserInfo: syncUserInfo);
    Alog.i(
        tag: 'ConversationKit',
        moduleName: 'ConversationRepo',
        content: 'getSessionList size:${conversationList?.length}');
    conversationList = _filterSession(conversationList);
    conversationList?.sort(comparator);
    if (!syncUserInfo) {
      ConversationRepo.instance._fillUserInfoAsync(_result.data);
    }
    return conversationList;
  }
  return null;
}