remember the library tab across restarts

The selected tab lived in rememberSaveable, which survives a rotation or a
process-death restore but not a cold start, so the app always came back on
Albums. It goes through DataStore now, like the per-tab sort and filters, which
were already durable - landing on a different tab than the one you had filtered
is what made the filters look reset.
This commit is contained in:
austinried
2026-10-04 00:30:04 +00:00
parent 684cc5a287
commit 270d749f0c
4 changed files with 37 additions and 4 deletions
@@ -45,6 +45,22 @@ class UserPreferencesTest {
file.delete()
}
@Test
fun theSelectedLibraryTabRoundTrips() =
runTest {
val file = File.createTempFile("user-prefs", ".preferences_pb").apply { delete() }
val store = PreferenceDataStoreFactory.create(scope = backgroundScope) { file }
val prefs = UserPreferences(store)
assertEquals("Albums", prefs.libraryTab().first())
prefs.setLibraryTab("Playlists")
assertEquals("Playlists", prefs.libraryTab().first())
file.delete()
}
@Test
fun aListQueryStoredBeforeTheDownloadedFilterStillDecodes() =
runTest {