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

Merged
reya merged 2 commits from fix/crash-on-new-chat into master 2026-05-24 01:30:48 +00:00
2 changed files with 10 additions and 2 deletions
Showing only changes of commit 93f285f02f - Show all commits

View File

@@ -110,7 +110,9 @@ fun HomeScreen(
?: remember { mutableStateOf(null) }
LaunchedEffect(Unit) {
viewModel.getChatRooms()
if (qrResult == null) {
viewModel.getChatRooms()
}
}
LaunchedEffect(qrResult) {

View File

@@ -436,7 +436,13 @@ class NostrViewModel(
fun getChatRooms() {
viewModelScope.launch {
_chatRooms.value = nostr.getChatRooms() ?: emptySet()
val rooms = nostr.getChatRooms() ?: emptySet()
_chatRooms.update { currentRooms ->
val virtualRooms = currentRooms.filter { local ->
rooms.none { db -> db.id == local.id }
}
rooms + virtualRooms
}
}
}