setConversationList static method
设置会话数据
Implementation
static void setConversationList(List<dynamic> list, { bool doClear = false }) {
if (list.isEmpty && doClear) {
conversationList.value = [];
needClearUnreadConversations.value = {};
setCatch('conversationList', jsonEncode(conversationList.value));
currentFocusConversation.value = null;
}
if (list.isNotEmpty) {
try {
if (doClear) {
conversationList.value = list.map((item) => ConversationItemEntity.fromJson(item)).toList();
} else {
List<ConversationItemEntity> all = [...conversationList.value, ...list.map((item) => ConversationItemEntity.fromJson(item))];
final seenIds = <String>{};
final result = all.where((item) => seenIds.add(item.conversationID)).toList();
conversationList.value = result;
}
needClearUnreadConversations.value = Set.from(
conversationList.value
.where((conversationItem) => conversationItem.unreadCount > 0)
.map((conversationItem) => conversationItem.conversationID)
.where((id) => id.isNotEmpty)
);
setCatch('conversationList', jsonEncode(conversationList.value));
_resetCurrentFocusConversationFromSession();
} catch (_) {}
}
}