From 7506ca599e53abcf51d5b492e909687b635f8737 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 14:16:35 +0000 Subject: [PATCH 1/2] fix: resolve Kotlin compiler warnings in commons and amethyst - PoWPublishQueue: use non-deprecated PersistentMap.putting()/removing() - NappletBrokerTest: drop cast that can never succeed after assertIs - PrivacyLockStateTest: remove redundant !! (smart-cast already non-null) - MinichatScreen: drop unnecessary !! on smart-cast non-null Strings - Concord screens: remove unnecessary safe calls on non-null ChannelEntity and ResponseBody, and the now-dead elvis fallbacks Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Myhus2x1c3BSWCtjenSmkf --- .../ui/screen/loggedIn/chats/minichat/MinichatScreen.kt | 4 ++-- .../publicChannels/concord/ConcordChannelListScreen.kt | 6 +++--- .../chats/publicChannels/concord/ConcordCommunityImage.kt | 4 ++-- .../chats/publicChannels/concord/ConcordHomeScreen.kt | 6 +++--- .../amethyst/commons/service/pow/PoWPublishQueue.kt | 4 ++-- .../amethyst/commons/napplet/NappletBrokerTest.kt | 1 - .../amethyst/commons/privacylock/PrivacyLockStateTest.kt | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/minichat/MinichatScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/minichat/MinichatScreen.kt index b7bc4e23bb..0189c58e3e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/minichat/MinichatScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/minichat/MinichatScreen.kt @@ -114,7 +114,7 @@ fun MinichatScreen( // public-chat (NIP-28/NIP-29) replies come over a relay REQ for this message's kind-1111 children. if (isConcord) { ConcordChannelSubscription(accountViewModel.dataSources().concordChannels, accountViewModel) - ConcordChannelHistorySubscription(communityId!!, channelId!!, accountViewModel.dataSources().concordChannelHistory, accountViewModel) + ConcordChannelHistorySubscription(communityId, channelId, accountViewModel.dataSources().concordChannelHistory, accountViewModel) ConcordMinichatBackfillUntilRoot(rootNote, accountViewModel.dataSources().concordChannelHistory.history) } EventFinderFilterAssemblerSubscription(rootNote, accountViewModel) @@ -151,7 +151,7 @@ fun MinichatScreen( // itself", where the whole timeline loads and (if you aren't a member yet) you can // join. This is the way out when the pinned root is still backfilling or unavailable. if (isConcord) { - IconButton(onClick = { nav.nav(Route.Concord(communityId!!, channelId!!)) }) { + IconButton(onClick = { nav.nav(Route.Concord(communityId, channelId)) }) { SymbolIcon(symbol = MaterialSymbols.Forum, contentDescription = stringRes(R.string.concord_open_channel)) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordChannelListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordChannelListScreen.kt index 1ec3fcc42f..a6cfb14e46 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordChannelListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordChannelListScreen.kt @@ -236,11 +236,11 @@ fun ConcordChannelListScreen( LazyColumn(Modifier.fillMaxSize().padding(padding)) { items(channels, key = { it.key }) { entry -> val def = entry.value.definition - val name = def?.name ?: entry.key + val name = def.name.ifBlank { entry.key } val icon = when { - def?.voice == true -> MaterialSymbols.Mic - def?.private == true -> MaterialSymbols.Lock + def.voice == true -> MaterialSymbols.Mic + def.private == true -> MaterialSymbols.Lock else -> MaterialSymbols.Tag } Row( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordCommunityImage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordCommunityImage.kt index c6f38c3dbf..c3d6864065 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordCommunityImage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordCommunityImage.kt @@ -72,8 +72,8 @@ fun rememberConcordImageModel( val ciphertext = client.newCall(Request.Builder().url(pointer.url).build()).execute().use { resp -> if (!resp.isSuccessful) return@runCatching null - resp.body?.bytes() - } ?: return@runCatching null + resp.body.bytes() + } val plaintext = pointer.decryptOrNull(ciphertext) ?: return@runCatching null cacheFile.writeBytes(plaintext) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordHomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordHomeScreen.kt index 632e929f77..a368f2429c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordHomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/concord/ConcordHomeScreen.kt @@ -222,11 +222,11 @@ fun ConcordHomeScreen( ConcordChannelRow( communityId = entry.id, channelKey = ch.key, - channelName = def?.name ?: ch.key, + channelName = def.name.ifBlank { ch.key }, icon = when { - def?.voice == true -> MaterialSymbols.Mic - def?.private == true -> MaterialSymbols.Lock + def.voice == true -> MaterialSymbols.Mic + def.private == true -> MaterialSymbols.Lock else -> MaterialSymbols.Tag }, hideIfRead = mode == ChannelExpand.UNREAD, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt index d590b9e344..38bef8672e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPublishQueue.kt @@ -280,7 +280,7 @@ class PoWPublishQueue( val job = MiningJob(id, kind, difficulty, persisted = persistAs != null, dedupeKey = dedupeKey, owner = owner, work = work) persistAs?.let { persistence?.save(it) } - pending.update { it.put(job.id, job) } + pending.update { it.putting(job.id, job) } _jobs.update { (it + PoWJobState(job.id, job.kind, job.difficulty)).toImmutableList() } Log.d(TAG) { val durability = if (persistAs != null) "persisted" else "in-memory only, lost on process death" @@ -409,7 +409,7 @@ class PoWPublishQueue( dropCheckpoint: Boolean, persisted: Boolean, ) { - pending.update { it.remove(jobId) } + pending.update { it.removing(jobId) } _jobs.update { list -> list.filter { it.id != jobId }.toImmutableList() } if (persisted && dropCheckpoint) persistence?.remove(jobId) } diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt index 963ef39d31..6e43798da5 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt @@ -439,7 +439,6 @@ class NappletBrokerTest { broker(ScriptedPrompt(GrantState.ALLOW_ONCE)) .handle(applet, NappletRequest.PayInvoice("lnbc1..."), allDeclared) assertIs(response) - assertNull((response as? NappletResponse.Paid)?.preimage) } @Test diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/privacylock/PrivacyLockStateTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/privacylock/PrivacyLockStateTest.kt index b6f44c35f7..645e214301 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/privacylock/PrivacyLockStateTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/privacylock/PrivacyLockStateTest.kt @@ -153,7 +153,7 @@ class PrivacyLockStateTest { state.onUnlockSuccess() advanceTimeBy(InactivityTimer.OneMin.millis!! - 1_000L) state.onUserInteraction() - advanceTimeBy(InactivityTimer.OneMin.millis!! - 1_000L) + advanceTimeBy(InactivityTimer.OneMin.millis - 1_000L) assertTrue(state.state.value is LockState.Unlocked) advanceTimeBy(2_000L) assertEquals(LockState.Locked, state.state.value) From f8f8dd59c2c08fde813a4f3a2d00b6f1c8d0eaa9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 14:38:39 +0000 Subject: [PATCH 2/2] fix: use non-deprecated PersistentMap.putting()/removing() in RelayAuthenticator Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Myhus2x1c3BSWCtjenSmkf --- .../quartz/nip01Core/relay/client/auth/RelayAuthenticator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/RelayAuthenticator.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/RelayAuthenticator.kt index a6e3493714..1c5bc662de 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/RelayAuthenticator.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/auth/RelayAuthenticator.kt @@ -96,7 +96,7 @@ class RelayAuthenticator( private fun publishSnapshot(relayUrl: NormalizedRelayUrl) { val status = authStatus.get(relayUrl) _authStateFlow.update { current -> - if (status == null) current.remove(relayUrl) else current.put(relayUrl, status.snapshot()) + if (status == null) current.removing(relayUrl) else current.putting(relayUrl, status.snapshot()) } }