|
|
@ -65,7 +65,6 @@ class HxDatabase { |
|
|
|
await _dbIsOpen(); |
|
|
|
await _dbIsOpen(); |
|
|
|
String sql = |
|
|
|
String sql = |
|
|
|
'SELECT * FROM (SELECT * FROM Message WHERE toId = ? OR fromId = ? ORDER BY time DESC) mm GROUP BY mm.toId,mm.fromId'; |
|
|
|
'SELECT * FROM (SELECT * FROM Message WHERE toId = ? OR fromId = ? ORDER BY time DESC) mm GROUP BY mm.toId,mm.fromId'; |
|
|
|
debugPrint("66666666666$sql"); |
|
|
|
|
|
|
|
return db.rawQuery(sql, [userId, userId]).then((value) { |
|
|
|
return db.rawQuery(sql, [userId, userId]).then((value) { |
|
|
|
return value.map((e) { |
|
|
|
return value.map((e) { |
|
|
|
debugPrint("Message: ${e}"); |
|
|
|
debugPrint("Message: ${e}"); |
|
|
@ -88,16 +87,13 @@ class HxDatabase { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future<Map<String, int>> messageUnreadCount( |
|
|
|
Future<Map<String, int>> messageUnreadCount(List<String> userIds, String selfUserId) async { |
|
|
|
List<String> userIds, String selfUserId) async { |
|
|
|
|
|
|
|
await _dbIsOpen(); |
|
|
|
await _dbIsOpen(); |
|
|
|
List<Message> messages = await db |
|
|
|
String userStr = userIds.join(","); |
|
|
|
.query("Message", |
|
|
|
debugPrint("userStr: $userStr"); |
|
|
|
where: 'fromId IN (?) AND toId = ? AND state = 0 AND isDelete = 0', |
|
|
|
List<Message> messages = await db.rawQuery( |
|
|
|
whereArgs: [] |
|
|
|
"SELECT * FROM Message WHERE fromId IN ($userStr) AND toId = $selfUserId AND state = 0 AND isDelete = 0", |
|
|
|
..addAll(userIds) |
|
|
|
).then((value) { |
|
|
|
..add(selfUserId)) |
|
|
|
|
|
|
|
.then((value) { |
|
|
|
|
|
|
|
return value.map((e) => Message.fromJson(e)).toList(); |
|
|
|
return value.map((e) => Message.fromJson(e)).toList(); |
|
|
|
}, onError: (error) { |
|
|
|
}, onError: (error) { |
|
|
|
debugPrint("Message-error: $error"); |
|
|
|
debugPrint("Message-error: $error"); |
|
|
|