diff --git a/app/src/main/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsViewModel.kt b/app/src/main/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsViewModel.kt index 0603568c..c5612ec5 100644 --- a/app/src/main/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsViewModel.kt +++ b/app/src/main/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsViewModel.kt @@ -9,6 +9,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow +import androidx.compose.runtime.snapshots.Snapshot import app.cash.molecule.RecompositionMode import app.cash.molecule.launchMolecule import com.mr3y.podcaster.core.data.PodcastsRepository @@ -68,8 +69,10 @@ internal fun SubscriptionsPresenter( if (podcasts.isEmpty() || episodes.isEmpty()) { delay(1000) - isSubscriptionsLoading = false - isEpisodesLoading = false + Snapshot.withMutableSnapshot { + isSubscriptionsLoading = false + isEpisodesLoading = false + } } } diff --git a/app/src/test/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsPresenterTest.kt b/app/src/test/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsPresenterTest.kt index 7a899460..8af82676 100644 --- a/app/src/test/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsPresenterTest.kt +++ b/app/src/test/kotlin/com/mr3y/podcaster/ui/presenter/subscriptions/SubscriptionsPresenterTest.kt @@ -50,9 +50,6 @@ class SubscriptionsPresenterTest : BasePresenterTest() { assertThat(currentState.episodes).isEmpty() currentState = awaitItem() assertThat(currentState.subscriptions).isEqualTo(listOf(Podcasts[0])) - // each episode addition triggers separate state update, and we added 2 episodes - assertThat(currentState.episodes).hasSize(1) - currentState = awaitItem() assertThat(currentState.episodes).hasSize(2) expectNoEvents()