Browse Source

发消息修改

wr_202303
zsw 4 months ago
parent
commit
148d75ad8d
  1. 18
      lib/im/im_view/im_page.dart

18
lib/im/im_view/im_page.dart

@ -127,7 +127,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
List<String> queryUserIds = userIds.where((u) => contacts.where((c) => c.userId == u).isEmpty).toList();
/// TODO: queryUserIds request Api
}
contactMap = groupBy(contacts, (p0) => p0.userId);
contactMap = contacts.lGroupBy((p0) => p0.userId).mGroupItem;
if (mounted) {
setState(() {});
@ -138,15 +138,19 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
Message message = await hxDatabase.lastMessage(userId);
if (message != null) {
lastMessageMap[userId] = message;
refreshState();
}
}
Map<S, T> groupBy<S, T>(Iterable<T> values, S Function(T) key) {
var map = <S, T>{};
for (var element in values) {
map[key(element)] ??= element;
}
return map;
void updateUnreadCount() async {
SharedPreferences shared = await SharedPreferences.getInstance();
String userId = shared.getString("userId");
unreadCountMap = await hxDatabase.messageUnreadCount(userIds, userId);
refreshState();
}
refreshState() {
if (mounted) setState(() {});
}
// queryMessage() async {

Loading…
Cancel
Save