refactor chat room connect

This commit is contained in:
2026-05-19 16:00:41 +07:00
parent 0104cf453d
commit e5710f376e
4 changed files with 109 additions and 80 deletions
@@ -373,16 +373,15 @@ class NostrViewModel(
return emptyList()
}
fun chatRoomConnect(roomId: Long) {
viewModelScope.launch {
try {
val room = getChatRoom(roomId)
val members = room.members
suspend fun chatRoomConnect(roomId: Long): Map<PublicKey, List<RelayUrl>> {
val room = getChatRoom(roomId)
val members = room.members
nostr.chatRoomConnect(roomId, members.toList())
} catch (e: Exception) {
showError("Error: ${e.message}")
}
return runCatching {
nostr.chatRoomConnect(members.toList())
}.getOrElse { e ->
showError("Error: ${e.message}")
members.associateWith { emptyList<RelayUrl>() }
}
}