[Room] Also query states for rooms
This commit is contained in:
parent
930404d149
commit
6cebee9eb7
|
@ -395,9 +395,11 @@ class Room {
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a Room from a json String which comes normally from the store.
|
/// Returns a Room from a json String which comes normally from the store. If the
|
||||||
|
/// state are also given, the method will await them.
|
||||||
static Future<Room> getRoomFromTableRow(
|
static Future<Room> getRoomFromTableRow(
|
||||||
Map<String, dynamic> row, Client matrix) async {
|
Map<String, dynamic> row, Client matrix,
|
||||||
|
{Future<List<Map<String, dynamic>>> states}) async {
|
||||||
String avatarUrl = row["avatar_url"];
|
String avatarUrl = row["avatar_url"];
|
||||||
if (avatarUrl == "")
|
if (avatarUrl == "")
|
||||||
avatarUrl = await matrix.store?.getAvatarFromSingleChat(row["id"]) ?? "";
|
avatarUrl = await matrix.store?.getAvatarFromSingleChat(row["id"]) ?? "";
|
||||||
|
|
|
@ -363,8 +363,8 @@ class Store {
|
||||||
" ORDER BY origin_server_ts DESC ");
|
" ORDER BY origin_server_ts DESC ");
|
||||||
List<Room> roomList = [];
|
List<Room> roomList = [];
|
||||||
for (num i = 0; i < res.length; i++) {
|
for (num i = 0; i < res.length; i++) {
|
||||||
Room room = await Room.getRoomFromTableRow(
|
Room room = await Room.getRoomFromTableRow(res[i], client,
|
||||||
res[i], client); // TODO: Also query the states for a room
|
states: getStatesFromRoomId(res[i]["id"]));
|
||||||
roomList.add(room);
|
roomList.add(room);
|
||||||
}
|
}
|
||||||
return roomList;
|
return roomList;
|
||||||
|
@ -375,7 +375,12 @@ class Store {
|
||||||
List<Map<String, dynamic>> res =
|
List<Map<String, dynamic>> res =
|
||||||
await db.rawQuery("SELECT * FROM Rooms WHERE id=?", [id]);
|
await db.rawQuery("SELECT * FROM Rooms WHERE id=?", [id]);
|
||||||
if (res.length != 1) return null;
|
if (res.length != 1) return null;
|
||||||
return Room.getRoomFromTableRow(res[0], client);
|
return Room.getRoomFromTableRow(res[0], client,
|
||||||
|
states: getStatesFromRoomId(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getStatesFromRoomId(String id) async {
|
||||||
|
return db.rawQuery("SELECT * FROM States WHERE room_id=?", [id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> forgetRoom(String roomID) async {
|
Future<void> forgetRoom(String roomID) async {
|
||||||
|
|
Loading…
Reference in a new issue