From 1b9fb442cf099ba754a5434a54e43dc299a0701e Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 19 Aug 2024 13:52:29 -0300 Subject: [PATCH] fix reject button not working --- .../ui/components/SingleEventHomeScreen.kt | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt index 98205093..b3088a81 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.greenart7c3.nostrsigner.LocalPreferences +import com.greenart7c3.nostrsigner.NostrSigner import com.greenart7c3.nostrsigner.R import com.greenart7c3.nostrsigner.database.AppDatabase import com.greenart7c3.nostrsigner.database.ApplicationEntity @@ -35,6 +36,7 @@ import com.greenart7c3.nostrsigner.models.kindToNip import com.greenart7c3.nostrsigner.service.AmberUtils import com.greenart7c3.nostrsigner.service.getAppCompatActivity import com.greenart7c3.nostrsigner.service.toShortenHex +import com.greenart7c3.nostrsigner.ui.NotificationType import com.greenart7c3.nostrsigner.ui.sendResult import com.vitorpamplona.quartz.crypto.CryptoUtils import com.vitorpamplona.quartz.encoders.bechToBytes @@ -471,11 +473,26 @@ fun SingleEventHomeScreen( ) }, { + onLoading(true) coroutineScope.launch(Dispatchers.IO) { if (key == "null") { return@launch } + val defaultRelays = NostrSigner.getInstance().settings.defaultRelays + val savedApplication = database.applicationDao().getByKey(key) + val relays = if (savedApplication != null) { + savedApplication.application.relays.ifEmpty { defaultRelays } + } else { + intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays + } + if (intentData.bunkerRequest != null) { + NostrSigner.getInstance().checkForNewRelays( + NostrSigner.getInstance().settings.notificationType != NotificationType.DIRECT, + relays.toSet(), + ) + } + if (remember.value) { AmberUtils.acceptOrRejectPermission( key, @@ -488,8 +505,6 @@ fun SingleEventHomeScreen( ) } - val savedApplication = database.applicationDao().getByKey(key) - val relays = intentData.bunkerRequest?.relays ?: listOf() val application = savedApplication ?: ApplicationWithPermissions( application = ApplicationEntity( @@ -520,19 +535,19 @@ fun SingleEventHomeScreen( false, ), ) - } - if (intentData.bunkerRequest != null) { - AmberUtils.sendBunkerError( - account, - intentData.bunkerRequest, - applicationEntity?.application?.relays ?: emptyList(), - context, - onLoading, - ) - } else { - context.getAppCompatActivity()?.intent = null - context.getAppCompatActivity()?.finish() + if (intentData.bunkerRequest != null) { + AmberUtils.sendBunkerError( + account, + intentData.bunkerRequest, + relays, + context, + onLoading, + ) + } else { + context.getAppCompatActivity()?.intent = null + context.getAppCompatActivity()?.finish() + } } }, )