From 918a575cfdc60de779d738857b6c0160cbacd6ce Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 28 Aug 2025 10:24:54 -0400 Subject: [PATCH 1/5] Speeds up first time logins by not waiting for Tor --- .../src/main/java/com/vitorpamplona/amethyst/Amethyst.kt | 5 +++-- .../java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt | 2 +- .../com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt index b0e7de2fc..038ae36dd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt @@ -117,10 +117,11 @@ class Amethyst : Application() { // Connects the NostrClient class with okHttp val websocketBuilder = OkHttpWebSocket.Builder { url -> + val useTor = torProxySettingsAnchor.useProxy(url) if (torProxySettingsAnchor.isDM(url)) { - okHttpClientForRelaysForDms.getHttpClient(torProxySettingsAnchor.useProxy(url)) + okHttpClientForRelaysForDms.getHttpClient(useTor) } else { - okHttpClientForRelays.getHttpClient(torProxySettingsAnchor.useProxy(url)) + okHttpClientForRelays.getHttpClient(useTor) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt index 11edf8e83..88b8f9d5d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt @@ -27,7 +27,7 @@ class TorSettings( val externalSocksPort: Int = 9050, val onionRelaysViaTor: Boolean = true, val dmRelaysViaTor: Boolean = true, - val newRelaysViaTor: Boolean = true, + val newRelaysViaTor: Boolean = false, val trustedRelaysViaTor: Boolean = false, val urlPreviewsViaTor: Boolean = false, val profilePicsViaTor: Boolean = false, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt index bf57fb3d1..e03726f57 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt @@ -27,7 +27,7 @@ class TorSettingsFlow( val externalSocksPort: MutableStateFlow = MutableStateFlow(9050), val onionRelaysViaTor: MutableStateFlow = MutableStateFlow(true), val dmRelaysViaTor: MutableStateFlow = MutableStateFlow(true), - val newRelaysViaTor: MutableStateFlow = MutableStateFlow(true), + val newRelaysViaTor: MutableStateFlow = MutableStateFlow(false), val trustedRelaysViaTor: MutableStateFlow = MutableStateFlow(false), val urlPreviewsViaTor: MutableStateFlow = MutableStateFlow(false), val profilePicsViaTor: MutableStateFlow = MutableStateFlow(false), From f536f8e88eab124960d0e86a27b1be61741c3d1e Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 28 Aug 2025 10:32:16 -0400 Subject: [PATCH 2/5] Fixes readonly crash on DVMs --- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 3e7c758de..100ef3ca7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1485,7 +1485,7 @@ class AccountViewModel( dvmPublicKey: User, onReady: (event: Note) -> Unit, ) { - viewModelScope.launch(Dispatchers.IO) { + runIOCatching { account.requestDVMContentDiscovery(dvmPublicKey) { onReady(LocalCache.getOrCreateNote(it.id)) } From 85ee48e003bfceb2628822ec085383f2e6a490f1 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 28 Aug 2025 10:32:29 -0400 Subject: [PATCH 3/5] Fixes crash when loading a user without a name --- .../vitorpamplona/quartz/nip01Core/metadata/MetadataEvent.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/metadata/MetadataEvent.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/metadata/MetadataEvent.kt index 7a0ab6f32..4c29468a9 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/metadata/MetadataEvent.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/metadata/MetadataEvent.kt @@ -117,7 +117,7 @@ class MetadataEvent( lnURL?.let { addIfNotBlank(currentMetadata, Lud06Tag.TAG_NAME, it.trim()) } return eventTemplate(KIND, currentMetadata.toString(), createdAt) { - alt("User profile for ${currentMetadata.get("name").asText() ?: "Anonymous"}") + alt("User profile for ${currentMetadata.get("name")?.asText() ?: "Anonymous"}") // For https://github.com/nostr-protocol/nips/pull/1770 currentMetadata.get(NameTag.TAG_NAME)?.asText()?.let { name(it) } @@ -132,7 +132,7 @@ class MetadataEvent( currentMetadata.get(Lud06Tag.TAG_NAME)?.asText()?.let { lud06(it) } twitter?.let { twitterClaim(it) } - ?: mastodon?.let { mastodonClaim(it) } + mastodon?.let { mastodonClaim(it) } github?.let { githubClaim(it) } initializer() From 4be1a143e602fd0ecd7dba5ad4ca7d689ee704b1 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 28 Aug 2025 10:35:44 -0400 Subject: [PATCH 4/5] Solving parsing issue with NWC --- .../vitorpamplona/quartz/nip47WalletConnect/Response.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Response.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Response.kt index 4968410be..b653d897b 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Response.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Response.kt @@ -37,9 +37,9 @@ class PayInvoiceSuccessResponse( val result: PayInvoiceResultParams? = null, ) : Response("pay_invoice") { class PayInvoiceResultParams( - val preimage: String, + val preimage: String? = null, ) { - fun countMemory(): Long = pointerSizeInBytes + preimage.bytesUsedInMemory() + fun countMemory(): Long = pointerSizeInBytes + (preimage?.bytesUsedInMemory() ?: 0) } override fun countMemory(): Long = pointerSizeInBytes + (result?.countMemory() ?: 0) @@ -49,8 +49,8 @@ class PayInvoiceErrorResponse( val error: PayInvoiceErrorParams? = null, ) : Response("pay_invoice") { class PayInvoiceErrorParams( - val code: ErrorType?, - val message: String?, + val code: ErrorType? = null, + val message: String? = null, ) { fun countMemory(): Long = pointerSizeInBytes + pointerSizeInBytes + (message?.bytesUsedInMemory() ?: 0) } From da5816a6c67edfcf5db52954fce4e7c4e172652c Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 28 Aug 2025 10:41:22 -0400 Subject: [PATCH 5/5] Fixes crash when pasting an invalid NIP-47 uri into the zap settings --- .../amethyst/ui/note/UpdateZapAmountDialog.kt | 9 ++++++++- amethyst/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt index 13a509257..68ab2cfbd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt @@ -341,7 +341,14 @@ fun UpdateZapAmountContent( IconButton( onClick = { - clipboardManager.getText()?.let { postViewModel.copyFromClipboard(it.text) } + val uri = clipboardManager.getText()?.text + try { + uri?.let { + postViewModel.copyFromClipboard(it) + } + } catch (e: IllegalArgumentException) { + accountViewModel.toastManager.toast(R.string.invalid_nip47_uri_title, R.string.invalid_nip47_uri_description) + } }, ) { Icon( diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 56255f73e..ae582b165 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -787,6 +787,10 @@ Paste from clipboard + Invalid NIP-47 URI + The URI %1$s is not a valid NIP-47 login URI. + + For the App\'s Interface Dark, Light or System theme Automatically load images and GIFs