From 24cb4db9a9be1c383bc51717930156a603bbee70 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Thu, 18 Jun 2026 23:29:28 +0300 Subject: [PATCH] Add todo to save the bundle --- .../repository/DatabaseNostrRepository.kt | 2 ++ .../view/model/ChatRoomCreationViewModel.kt | 29 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/at/torch/compose/database/repository/DatabaseNostrRepository.kt b/composeApp/src/commonMain/kotlin/at/torch/compose/database/repository/DatabaseNostrRepository.kt index 8429aafd..e52fa872 100644 --- a/composeApp/src/commonMain/kotlin/at/torch/compose/database/repository/DatabaseNostrRepository.kt +++ b/composeApp/src/commonMain/kotlin/at/torch/compose/database/repository/DatabaseNostrRepository.kt @@ -213,6 +213,8 @@ class DatabaseNostrRepository( val identity = publicKey.hexToByteArray() val bundle = generateKeyPackage(identity, dTag) + // TODO: Save the bundle? + val keyPackageBytes = bundle.keyPackage.toTlsBytes() val keyPackageBase64 = Base64.encode(keyPackageBytes) val keyPackageRef = bundle.keyPackage.reference().toHexKey() diff --git a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ChatRoomCreationViewModel.kt b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ChatRoomCreationViewModel.kt index 0f7ab194..6b31dc54 100644 --- a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ChatRoomCreationViewModel.kt +++ b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ChatRoomCreationViewModel.kt @@ -83,23 +83,28 @@ class ChatRoomCreationViewModel( chatRoomId = group.groupId.toHex(), activeUserPublicKey = keyPair.pubKey.toHexKey(), relayHint = null, - defaultSubject = null, + defaultSubject = name.toString(), mlsGroupState = group.saveState().encodeTls().toHex() ) - if (localChatRoom == null) { - onNavigateToChatRoom.invoke( - ImplementationPendingRoute("Something went wrong") - ) - } else { - onNavigateToChatRoom.invoke( - ChatRoomDetailRoute( - activeUserPublicKey = keyPair.pubKey.toHexKey(), - chatRoomId = localChatRoom.chatRoom.id, - relayHint = null + viewModelScope.launch(Dispatchers.Main) { + if (localChatRoom != null) { + // TODO: Broadcast the thing... + // TODO: Navigate to invitation screen... + onNavigateToChatRoom.invoke( + ChatRoomDetailRoute( + activeUserPublicKey = keyPair.pubKey.toHexKey(), + chatRoomId = localChatRoom.chatRoom.id, + relayHint = null + ) ) - ) + } else { + onNavigateToChatRoom.invoke( + ImplementationPendingRoute("Something went wrong") + ) + } } + } } }