addMessageNative static method
发送消息后添加聊天消息 - 原生平台
Implementation
static void addMessageNative(Map<String, dynamic> msgInfo) {
try {
Map<String, List<Map<String, dynamic>>> newConfig = Map.from(messageListNativeConfig.value);
List<Map<String, dynamic>> conversationIDAboutMsgList = newConfig[msgInfo['message_conv_id']] ?? [];
if (conversationIDAboutMsgList.where((find) => find['message_msg_id'] == msgInfo['message_msg_id']).isEmpty) {
conversationIDAboutMsgList.add(msgInfo);
conversationIDAboutMsgList.sort((a, b) {
int timeCompare = a['message_client_time'].compareTo(b['message_client_time']);
if (timeCompare != 0) return timeCompare;
int aSeq = a['message_seq'];
int bSeq = b['message_seq'];
int seqCompare = aSeq.compareTo(bSeq);
return seqCompare;
});
newConfig[msgInfo['message_conv_id']] = conversationIDAboutMsgList;
messageListNativeConfig.value = newConfig;
setCatch('messageListConfig', jsonEncode(messageListNativeConfig.value));
}
} catch (_) {}
}