getSingleRoom method
Implementation
@override
Future<Room?> getSingleRoom(Client client, String roomId,
{bool loadImportantStates = true}) async {
// Get raw room from database:
final roomData = await _roomsBox.get(roomId);
if (roomData == null) return null;
final room = Room.fromJson(convertToJson(roomData), client);
// Get important states:
if (loadImportantStates) {
final dbKeys = client.importantStateEvents
.map((state) => TupleKey(roomId, state).toString())
.toList();
final rawStates = await Future.wait(
dbKeys.map((key) => _roomStateBox.get(key)),
);
for (final rawState in rawStates) {
if (rawState == null || rawState[''] == null) continue;
room.setState(Event.fromJson(convertToJson(rawState['']), room));
}
}
return room;
}