build method
Implementation
@override
Future<Room?> build(String arg) async {
// if we are in chat showcase mode, return a mock room
if (includeChatShowcase &&
mockChatList.any((mockChatItem) => mockChatItem.roomId == arg)) {
return mockChatList
.firstWhere((mockChatItem) => mockChatItem.roomId == arg)
.mockRoom;
}
// otherwise, get the room from the client
final client = await ref.watch(alwaysClientProvider.future);
_listener = client.subscribeRoomStream(arg); // keep it resident in memory
_poller = _listener.listen(
(data) async {
_log.info('seen update for room $arg');
state = await AsyncValue.guard(() async => await _getRoom(client));
},
onError: (e, s) {
_log.severe('room stream errored', e, s);
},
onDone: () {
_log.info('room stream ended');
},
);
ref.onDispose(() => _poller.cancel());
return await _getRoom(client);
}