From 62d341bd8a15d3901b6c5b6d744b63d807fa42a6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 27 Aug 2024 11:49:43 -0400 Subject: [PATCH] Publishing new user's events --- .../amethyst/ui/screen/AccountStateViewModel.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt index a1343bc86..18eec226d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt @@ -33,6 +33,7 @@ import com.vitorpamplona.amethyst.model.DefaultDMRelayList import com.vitorpamplona.amethyst.model.DefaultNIP65List import com.vitorpamplona.amethyst.model.DefaultSearchRelayList import com.vitorpamplona.amethyst.service.Nip05NostrAddressVerifier +import com.vitorpamplona.ammolite.relays.Client import com.vitorpamplona.ammolite.relays.Constants import com.vitorpamplona.ammolite.service.HttpClientManager import com.vitorpamplona.quartz.crypto.CryptoUtils @@ -53,7 +54,9 @@ import com.vitorpamplona.quartz.signers.NostrSignerSync import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.debounce @@ -298,6 +301,15 @@ class AccountStateViewModel : ViewModel() { LocalPreferences.updatePrefsForLogin(accountSettings) startUI(accountSettings) + + GlobalScope.launch(Dispatchers.IO) { + delay(2000) // waits for the new user to connect to the new relays. + accountSettings.backupUserMetadata?.let { Client.send(it) } + accountSettings.backupContactList?.let { Client.send(it) } + accountSettings.backupNIP65RelayList?.let { Client.send(it) } + accountSettings.backupDMRelayList?.let { Client.send(it) } + accountSettings.backupSearchRelayList?.let { Client.send(it) } + } } }