chore: fix app crash when create new room via QR (#3)

Reviewed-on: https://git.reya.su/reya/coop-mobile/pulls/3
This commit is contained in:
2026-05-24 01:30:48 +00:00
parent 2d25cb36bd
commit 44acbfa6b7
4 changed files with 45 additions and 22 deletions
@@ -68,8 +68,19 @@ fun ChatScreen(
val snackbarHostState = LocalSnackbarHostState.current
val viewModel = LocalNostrViewModel.current
val room = viewModel.getChatRoom(id)
val listState = rememberLazyListState()
val chatRooms by viewModel.chatRooms.collectAsState()
val room = remember(chatRooms, id) { chatRooms.firstOrNull { it.id == id } }
if (room == null) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
LoadingIndicator()
}
return
}
val displayName by remember(room) { room.displayNameFlow(viewModel) }.collectAsState("Loading...")
val picture by remember(room) { room.pictureFlow(viewModel) }.collectAsState(null)