From fc971c518cb9cbfad58b74367fa572f87243548d Mon Sep 17 00:00:00 2001 From: zyrouge Date: Thu, 11 Jan 2024 18:06:14 +0530 Subject: [PATCH] fix: incorrect albums songs sort (#409 --- .../zyrouge/symphony/services/Settings.kt | 3 ++- .../symphony/ui/components/SongList.kt | 23 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt b/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt index d63bdc5c..1105f63a 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt @@ -185,7 +185,8 @@ class SettingsManager(private val symphony: Symphony) { val lastUsedPlaylistSongsSortReverse = _lastUsedPlaylistSongsSortReverse.asStateFlow() private val _lastUsedAlbumSongsSortBy = MutableStateFlow(getLastUsedAlbumSongsSortBy()) val lastUsedAlbumSongsSortBy = _lastUsedAlbumSongsSortBy.asStateFlow() - private val _lastUsedAlbumSongsSortReverse = MutableStateFlow(getLastUsedAlbumsSortReverse()) + private val _lastUsedAlbumSongsSortReverse = + MutableStateFlow(getLastUsedAlbumSongsSortReverse()) val lastUsedAlbumSongsSortReverse = _lastUsedAlbumSongsSortReverse.asStateFlow() private val _lastUsedTreePathSortBy = MutableStateFlow(getLastUsedTreePathSortBy()) val lastUsedTreePathSortBy = _lastUsedTreePathSortBy.asStateFlow() diff --git a/app/src/main/java/io/github/zyrouge/symphony/ui/components/SongList.kt b/app/src/main/java/io/github/zyrouge/symphony/ui/components/SongList.kt index 5765ab2f..75ab657b 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/ui/components/SongList.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/ui/components/SongList.kt @@ -146,12 +146,10 @@ fun SongListType.getLastUsedSortBy(context: ViewContext) = when (this) { SongListType.Playlist -> context.symphony.settings.lastUsedPlaylistSongsSortBy } -fun SongListType.setLastUsedSortBy(context: ViewContext, sort: SongSortBy) { - when (this) { - SongListType.Default -> context.symphony.settings.setLastUsedSongsSortBy(sort) - SongListType.Playlist -> context.symphony.settings.setLastUsedPlaylistSongsSortBy(sort) - SongListType.Album -> context.symphony.settings.setLastUsedAlbumSongsSortBy(sort) - } +fun SongListType.setLastUsedSortBy(context: ViewContext, sort: SongSortBy) = when (this) { + SongListType.Default -> context.symphony.settings.setLastUsedSongsSortBy(sort) + SongListType.Playlist -> context.symphony.settings.setLastUsedPlaylistSongsSortBy(sort) + SongListType.Album -> context.symphony.settings.setLastUsedAlbumSongsSortBy(sort) } fun SongListType.getLastUsedSortReverse(context: ViewContext) = when (this) { @@ -160,13 +158,8 @@ fun SongListType.getLastUsedSortReverse(context: ViewContext) = when (this) { SongListType.Album -> context.symphony.settings.lastUsedAlbumSongsSortReverse } -fun SongListType.setLastUsedSortReverse(context: ViewContext, reverse: Boolean) { - when (this) { - SongListType.Default -> context.symphony.settings.setLastUsedSongsSortReverse(reverse) - SongListType.Playlist -> context.symphony.settings.setLastUsedPlaylistSongsSortReverse( - reverse - ) - - SongListType.Album -> context.symphony.settings.setLastUsedAlbumSongsSortReverse(reverse) - } +fun SongListType.setLastUsedSortReverse(context: ViewContext, reverse: Boolean) = when (this) { + SongListType.Default -> context.symphony.settings.setLastUsedSongsSortReverse(reverse) + SongListType.Playlist -> context.symphony.settings.setLastUsedPlaylistSongsSortReverse(reverse) + SongListType.Album -> context.symphony.settings.setLastUsedAlbumSongsSortReverse(reverse) }