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(copyMap(roomData), client);
// Get important states:
if (loadImportantStates) {
final dbKeys = client.importantStateEvents
.map((state) => TupleKey(roomId, state).toString())
.toList();
final rawStates = await _roomStateBox.getAll(dbKeys);
for (final rawState in rawStates) {
if (rawState == null || rawState[''] == null) continue;
room.setState(Event.fromJson(copyMap(rawState['']), room));
}
}
return room;
}