From 4afa7fed87bb939500cbd83f21e8a3208500d935 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Fri, 10 Jul 2026 23:59:11 +0200 Subject: [PATCH] Add rebroadcast of profile --- .../ui/composable/ShareProfileScreen.kt | 19 ++++++++++++++++++- .../ui/view/model/ShareProfileViewModel.kt | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/composable/ShareProfileScreen.kt b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/composable/ShareProfileScreen.kt index 44be1a12..c3d7d98d 100644 --- a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/composable/ShareProfileScreen.kt +++ b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/composable/ShareProfileScreen.kt @@ -111,7 +111,7 @@ fun ShareProfileScreen( modifier = Modifier.padding(innerPadding) ) { LazyColumn( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth().weight(1f), verticalArrangement = Arrangement.spacedBy(10.dp), horizontalAlignment = Alignment.CenterHorizontally ) { @@ -186,6 +186,23 @@ fun ShareProfileScreen( } } + + Row( + modifier = Modifier.fillMaxWidth().padding(20.dp), + horizontalArrangement = Arrangement.Center + ) { + Button( + onClick = { + shareProfileViewModel.rebroadcastProfile( + localNostrEvent = shareProfileUIState.localNostrEvent + ) + } + ) { + Text( + "Re-broadcast" + ) + } + } } } } diff --git a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ShareProfileViewModel.kt b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ShareProfileViewModel.kt index 84c6ed22..fa9db139 100755 --- a/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ShareProfileViewModel.kt +++ b/composeApp/src/commonMain/kotlin/at/torch/compose/ui/view/model/ShareProfileViewModel.kt @@ -8,6 +8,9 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewmodel.initializer import androidx.lifecycle.viewmodel.viewModelFactory +import at.torch.compose.database.model.BroadcastNostrEventRequest +import at.torch.compose.database.model.intermdiate.LocalNostrEvent +import at.torch.compose.nostr.Relays import at.torch.compose.ui.view.state.ShareProfileUIState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent @@ -48,6 +51,20 @@ class ShareProfileViewModel( } } + fun rebroadcastProfile(localNostrEvent: LocalNostrEvent) { + viewModelScope.launch(Dispatchers.IO) { + // Rebroadcast + nostrRepository.rescheduleBroadcastNostrEventRequests( + Relays.eventFinderRelaySet.map { + BroadcastNostrEventRequest( + nostrEventId = localNostrEvent.nostrEvent.id, + relayURL = it.url + ) + } + ) + } + } + companion object { const val TAG = "ShareProfileViewModel"