mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
drop the speculative legacy album sort migration
This commit is contained in:
@@ -42,17 +42,7 @@ private val Context.preferences: DataStore<Preferences> by preferencesDataStore(
|
|||||||
class UserPreferences(
|
class UserPreferences(
|
||||||
private val store: DataStore<Preferences>,
|
private val store: DataStore<Preferences>,
|
||||||
) {
|
) {
|
||||||
fun listQuery(tab: LibraryListTab): Flow<ListQuery> =
|
fun listQuery(tab: LibraryListTab): Flow<ListQuery> = store.data.map { prefs -> decode(prefs[listQueryKey(tab)], tab.defaultSort) }
|
||||||
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(
|
suspend fun setListQuery(
|
||||||
tab: LibraryListTab,
|
tab: LibraryListTab,
|
||||||
@@ -93,7 +83,6 @@ class UserPreferences(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
val ALBUM_SORT = stringPreferencesKey("album_sort")
|
|
||||||
val MAX_BITRATE = intPreferencesKey("max_bitrate")
|
val MAX_BITRATE = intPreferencesKey("max_bitrate")
|
||||||
val STREAM_FORMAT = stringPreferencesKey("stream_format")
|
val STREAM_FORMAT = stringPreferencesKey("stream_format")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user