From 0d58d94ef4a895931b2c4fdd0ce764f3d8181e63 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 21:13:23 +0000 Subject: [PATCH] fix: resolve CI lint error and coroutines opt-in warnings - Collect ConcordSession.state via collectAsStateWithLifecycle instead of reading StateFlow.value in composition (fixes StateFlowValueCalledInComposition lint error in GroupBottomBarEntries.kt). - Add @OptIn(ExperimentalCoroutinesApi::class) for testScheduler.advanceTimeBy and runCurrent usages in ResourceUsageLedgerTest and RelayAuthPromptBusTest. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Wx8SvzsWsru7rEQ1KcbSCW --- .../ui/navigation/bottombars/GroupBottomBarEntries.kt | 9 +++------ .../authCommand/model/RelayAuthPromptBusTest.kt | 2 ++ .../service/resourceusage/ResourceUsageLedgerTest.kt | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/GroupBottomBarEntries.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/GroupBottomBarEntries.kt index 242dcf9eef..eaac107c57 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/GroupBottomBarEntries.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/GroupBottomBarEntries.kt @@ -46,6 +46,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.concor import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip29RelayGroups.GroupId +import kotlinx.coroutines.flow.MutableStateFlow /** * The resolved presentation of a pinned chat/group [BottomBarEntry] — enough to render its avatar in @@ -153,12 +154,8 @@ fun rememberConcordEntryDisplay( val communities by account.concordChannelList.liveCommunities.collectAsStateWithLifecycle() val session = remember(entry.communityId, revision) { account.concordSessions.sessionFor(entry.communityId) } - val metadata = - session - ?.state - ?.value - .takeIf { revision >= 0 } - ?.metadata + val state by (session?.state ?: remember { MutableStateFlow(null) }).collectAsStateWithLifecycle() + val metadata = state.takeIf { revision >= 0 }?.metadata val fallbackName = remember(communities, entry.communityId) { communities.firstOrNull { it.id == entry.communityId }?.name?.ifBlank { null } } val label = metadata?.name?.takeIf { it.isNotBlank() } ?: fallbackName ?: stringRes(R.string.concord_home_title) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/RelayAuthPromptBusTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/RelayAuthPromptBusTest.kt index e3e71b44de..70f3a8d30f 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/RelayAuthPromptBusTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/RelayAuthPromptBusTest.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.service.relayClient.authCommand.model import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runCurrent @@ -70,6 +71,7 @@ class RelayAuthPromptBusTest { assertEquals(UserAuthChoice.DISMISS, bus.requestDecision(relay, emptyList())) } + @OptIn(ExperimentalCoroutinesApi::class) @Test fun retainsPromptForALateSubscriberSoItIsNotLost() = runTest { diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt index 6be24d2942..ac4c066788 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt @@ -27,6 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals @@ -142,6 +143,7 @@ class ResourceUsageAccountantTest { assertEquals(12L, store.allDays()[200]?.get("x")) } + @OptIn(ExperimentalCoroutinesApi::class) @Test fun hookAddsAreDrainedInPlaceAndNeverRearmTheFlushLoop() = runTest {