Merge pull request #3581 from vitorpamplona/claude/kotlin-coroutines-opt-in-t940p3

Fix reactive state handling in Concord entry display
This commit is contained in:
Vitor Pamplona
2026-07-15 17:23:21 -04:00
committed by GitHub
3 changed files with 7 additions and 6 deletions
@@ -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)
@@ -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 {
@@ -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 {