address review round 3: keep the search bar across recomposition, fix tab landing, page the queried songs queue

This commit is contained in:
austinried
2026-10-04 00:29:56 +00:00
parent 605bd1a6c6
commit f5948812bb
4 changed files with 245 additions and 30 deletions
@@ -42,7 +42,17 @@ private val Context.preferences: DataStore<Preferences> by preferencesDataStore(
class UserPreferences(
private val store: DataStore<Preferences>,
) {
fun listQuery(tab: LibraryListTab): Flow<ListQuery> = store.data.map { prefs -> decode(prefs[listQueryKey(tab)], tab.defaultSort) }
fun listQuery(tab: LibraryListTab): Flow<ListQuery> =
store.data.map { prefs -> decode(prefs[listQueryKey(tab)] ?: legacyQuery(prefs, tab), tab.defaultSort) }
private fun legacyQuery(
prefs: Preferences,
tab: LibraryListTab,
): String? {
if (tab != LibraryListTab.Albums) return null
val sort = prefs[ALBUM_SORT]?.let { if (it == "RecentlyAdded") "Added" else it } ?: return null
return "$sort|0|0"
}
suspend fun setListQuery(
tab: LibraryListTab,
@@ -83,6 +93,7 @@ class UserPreferences(
}
private companion object {
val ALBUM_SORT = stringPreferencesKey("album_sort")
val MAX_BITRATE = intPreferencesKey("max_bitrate")
val STREAM_FORMAT = stringPreferencesKey("stream_format")
}