fillSessionInfo static method
补充会话信息,会话列表中的个人信息和群组信息都在这里填充
Implementation
static Future<List<ConversationInfo>?> fillSessionInfo(
List<NIMSession>? infoList,
{bool fillUserInfo = true}) async {
if (infoList == null) {
return null;
}
List<ConversationInfo> conversationList = [];
List<String>? muteList;
if (fillUserInfo) {
muteList = (await NimCore.instance.userService.getMuteList()).data;
}
for (int i = 0; i < infoList.length; ++i) {
var e = infoList[i];
var conversationInfo = ConversationInfo(e);
conversationInfo.isStickTop = await getIt<MessageProvider>()
.isStickSession(e.sessionId, e.sessionType);
Alog.d(
tag: 'ConversationKit',
moduleName: 'ConversationRepo',
content: '${e.sessionId} isStickTop:${conversationInfo.isStickTop}');
if (e.sessionType == NIMSessionType.p2p && fillUserInfo) {
ConversationInfo res = await _fillUserInfo(conversationInfo);
if (muteList?.contains(res.session.sessionId) == true) {
res.mute = true;
}
conversationList.add(res);
} else if (e.sessionType == NIMSessionType.team) {
ConversationInfo res = await _fillTeamInfo(conversationInfo);
conversationList.add(res);
} else {
conversationList.add(conversationInfo);
}
}
return conversationList;
}