diff --git a/domain/core/src/main/kotlin/com/tangem/domain/core/lce/LceFlow.kt b/domain/core/src/main/kotlin/com/tangem/domain/core/lce/LceFlow.kt index 037775753e..65e29bca2b 100644 --- a/domain/core/src/main/kotlin/com/tangem/domain/core/lce/LceFlow.kt +++ b/domain/core/src/main/kotlin/com/tangem/domain/core/lce/LceFlow.kt @@ -6,7 +6,6 @@ import com.tangem.domain.core.utils.lceContent import com.tangem.domain.core.utils.lceError import com.tangem.domain.core.utils.lceLoading import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.channels.ProducerScope import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.flow.Flow @@ -38,13 +37,9 @@ class LceFlowScope @PublishedApi internal constructor( val isLoading: AtomicBoolean = AtomicBoolean(value = true) /** - * Sends a error of type [E] within the [ProducerScope] and then closes it for send. - * All subsequent sends will be ignored. + * Sends an error of type [E] within the [ProducerScope] without closing. * - * This method blocks the coroutine until a error is handled by the receiver. - * - * If the [ProducerScope] is already closed for send (e.g. after rising another error), it just raises [r] - * without closing. + * This method blocks the coroutine until an error is handled by the receiver. * * @param r Error to raise. */ @@ -52,7 +47,6 @@ class LceFlowScope @PublishedApi internal constructor( isLoading.set(false) producerScope.trySendBlocking(r.lceError()) - producerScope.close() raise.raise(r.lceError()) } @@ -88,14 +82,9 @@ class LceFlowScope @PublishedApi internal constructor( * * This method suspends until the [Lce] instance is handled by the receiver. * - * If the [ProducerScope] is closed for send (e.g. after rising a error), it does nothing. - * * @param value The [Lce] instance to send. */ - @OptIn(DelicateCoroutinesApi::class) suspend fun send(value: Lce) { - if (producerScope.isClosedForSend) return - isLoading.set(value.isLoading()) producerScope.send(value) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenList.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenList.kt index f5eaf0b0e3..2bd9431825 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenList.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenList.kt @@ -42,7 +42,7 @@ sealed class TokenList { ) : TokenList() /** Represents a state where the token list is empty. */ - object Empty : TokenList() { + data object Empty : TokenList() { override val totalFiatBalance: TotalFiatBalance = TotalFiatBalance.Loaded( amount = BigDecimal.ZERO, diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt index cc96309f1f..f56873489c 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesLceOperations.kt @@ -75,10 +75,9 @@ internal class CurrenciesStatusesLceOperations( ::createCurrenciesStatuses, ) .distinctUntilChanged() - .mapLatest { maybeCurrenciesStatuses -> + .collectLatest { maybeCurrenciesStatuses -> send(maybeCurrenciesStatuses) } - .launchIn(scope = this) } }