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