From 2e2c8d36c1e23bf274c7c19f1242e14b0c7afbc1 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:00:56 +0600 Subject: [PATCH] Make sure random library sort is at the bottom --- .../library/LibrarySettingsDialog.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt index 8410cfb40..0587cbe24 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt @@ -166,23 +166,27 @@ private fun ColumnScope.SortPage( val sortingMode = category.sort.type val sortDescending = !category.sort.isAscending - val trackerSortOption = if (trackers.isEmpty()) { - emptyList() - } else { - listOf(MR.strings.action_sort_tracker_score to LibrarySort.Type.TrackerMean) + val options = remember(trackers.isEmpty()) { + val trackerMeanPair = if (trackers.isNotEmpty()) { + MR.strings.action_sort_tracker_score to LibrarySort.Type.TrackerMean + } else { + null + } + listOfNotNull( + MR.strings.action_sort_alpha to LibrarySort.Type.Alphabetical, + MR.strings.action_sort_total to LibrarySort.Type.TotalChapters, + MR.strings.action_sort_last_read to LibrarySort.Type.LastRead, + MR.strings.action_sort_last_manga_update to LibrarySort.Type.LastUpdate, + MR.strings.action_sort_unread_count to LibrarySort.Type.UnreadCount, + MR.strings.action_sort_latest_chapter to LibrarySort.Type.LatestChapter, + MR.strings.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate, + MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded, + trackerMeanPair, + MR.strings.action_sort_random to LibrarySort.Type.Random, + ) } - listOf( - MR.strings.action_sort_alpha to LibrarySort.Type.Alphabetical, - MR.strings.action_sort_total to LibrarySort.Type.TotalChapters, - MR.strings.action_sort_last_read to LibrarySort.Type.LastRead, - MR.strings.action_sort_last_manga_update to LibrarySort.Type.LastUpdate, - MR.strings.action_sort_unread_count to LibrarySort.Type.UnreadCount, - MR.strings.action_sort_latest_chapter to LibrarySort.Type.LatestChapter, - MR.strings.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate, - MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded, - MR.strings.action_sort_random to LibrarySort.Type.Random, - ).plus(trackerSortOption).map { (titleRes, mode) -> + options.map { (titleRes, mode) -> if (mode == LibrarySort.Type.Random) { BaseSortItem( label = stringResource(titleRes),