diff --git a/app/src/main/kotlin/com/subtracks/ui/library/LibraryScreen.kt b/app/src/main/kotlin/com/subtracks/ui/library/LibraryScreen.kt index 551af84f..9c4934ed 100644 --- a/app/src/main/kotlin/com/subtracks/ui/library/LibraryScreen.kt +++ b/app/src/main/kotlin/com/subtracks/ui/library/LibraryScreen.kt @@ -335,6 +335,7 @@ fun LibraryScreen( HorizontalPager( state = pagerState, modifier = Modifier.fillMaxSize(), + beyondViewportPageCount = 1, ) { page -> val pageTab = LibraryTab.entries[page] val resetKey = resetKeys[pageTab] diff --git a/app/src/test/kotlin/com/subtracks/ui/LibraryScreenTest.kt b/app/src/test/kotlin/com/subtracks/ui/LibraryScreenTest.kt index 2e5ed1d5..1fa99357 100644 --- a/app/src/test/kotlin/com/subtracks/ui/LibraryScreenTest.kt +++ b/app/src/test/kotlin/com/subtracks/ui/LibraryScreenTest.kt @@ -32,7 +32,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test @@ -112,7 +111,7 @@ class LibraryScreenTest { } @Test - fun onlyTheVisibleTabCollectsItsPagingFlow() { + fun theVisibleTabAndItsNeighbourCollectTheirPagingFlows() { val collected = CopyOnWriteArrayList() val albums = flow> { @@ -147,10 +146,10 @@ class LibraryScreenTest { } } - composeRule.waitUntil(timeoutMillis = 5_000) { collected.isNotEmpty() } + composeRule.waitUntil(timeoutMillis = 5_000) { collected.contains("artists") } composeRule.waitForIdle() - assertEquals(listOf("albums"), collected.toList()) + assertEquals(listOf("albums", "artists"), collected.toList()) } @Test @@ -204,7 +203,6 @@ class LibraryScreenTest { assertTrue("returning to a tab should render its content", collected.contains("albums")) assertTrue("the tab that was shown should collect its flow", collected.contains("artists")) - assertFalse("inactive tabs should not collect their flows", collected.contains("playlists")) } @Test