Remove alphabetical category/feed sort option (mihonapp/mihon#1781)

Co-authored-by: cuong-tran <cuongtran.tm@gmail.com>
(cherry picked from commit 2b0c28938bfd74577d2ff0736b2cc72f4e4705cf)
This commit is contained in:
AntsyLich 2025-02-27 13:11:41 +06:00 committed by Cuong-Tran
parent d4157803ac
commit 8cd3243709
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
14 changed files with 7 additions and 206 deletions

View file

@ -35,6 +35,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- Fix App's preferences referencing deleted categories ([@cuong-tran](https://github.com/cuong-tran)) ([#1734](https://github.com/mihonapp/mihon/pull/1734))
- Fix backup/restore of category related preferences ([@cuong-tran](https://github.com/cuong-tran)) ([#1726](https://github.com/mihonapp/mihon/pull/1726))
### Removed
- Remove alphabetical category sort option
### Other
- Add zoned "Current time" to debug info and include year & timezone in logcat output ([@MajorTanya](https://github.com/MajorTanya)) ([#1672](https://github.com/mihonapp/mihon/pull/1672))

View file

@ -6,8 +6,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SortByAlpha
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -17,7 +15,6 @@ import eu.kanade.presentation.browse.components.FeedOrderListItem
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarTitle
import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedState
import kotlinx.collections.immutable.persistentListOf
import sh.calvin.reorderable.ReorderableItem
import sh.calvin.reorderable.rememberReorderableLazyListState
import tachiyomi.domain.source.model.FeedSavedSearch
@ -36,7 +33,6 @@ fun SourceFeedOrderScreen(
state: SourceFeedState,
onClickDelete: (FeedSavedSearch) -> Unit,
onChangeOrder: (FeedSavedSearch, Int) -> Unit,
onClickSortAlphabetically: () -> Unit,
navigateUp: (() -> Unit)? = null,
) {
Scaffold(
@ -46,15 +42,6 @@ fun SourceFeedOrderScreen(
AppBarTitle(stringResource(KMR.strings.action_sort_feed))
},
navigateUp = navigateUp,
actions = {
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_sort),
icon = Icons.Outlined.SortByAlpha,
onClick = onClickSortAlphabetically,
),
)
},
isActionMode = false,
scrollBehavior = scrollBehavior,
)

View file

@ -29,7 +29,6 @@ import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import tachiyomi.domain.source.model.FeedSavedSearch
import tachiyomi.i18n.MR
import tachiyomi.i18n.kmk.KMR
import tachiyomi.i18n.sy.SYMR
import tachiyomi.presentation.core.i18n.stringResource
@ -171,33 +170,4 @@ private fun FeedActionsDialogPreview() {
onClickDelete = { },
)
}
@Composable
fun FeedSortAlphabeticallyDialog(
onDismissRequest: () -> Unit,
onSort: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismissRequest,
confirmButton = {
TextButton(onClick = {
onSort()
onDismissRequest()
}) {
Text(text = stringResource(MR.strings.action_ok))
}
},
dismissButton = {
TextButton(onClick = onDismissRequest) {
Text(text = stringResource(MR.strings.action_cancel))
}
},
title = {
Text(text = stringResource(KMR.strings.action_sort_feed))
},
text = {
Text(text = stringResource(KMR.strings.sort_feed_confirmation))
},
)
}
// KMK <--

View file

@ -8,8 +8,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SortByAlpha
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -19,10 +17,8 @@ import androidx.compose.ui.Modifier
import eu.kanade.presentation.category.components.CategoryFloatingActionButton
import eu.kanade.presentation.category.components.CategoryListItem
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.tachiyomi.ui.category.CategoryScreenState
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import sh.calvin.reorderable.ReorderableItem
import sh.calvin.reorderable.rememberReorderableLazyListState
import tachiyomi.domain.category.model.Category
@ -38,7 +34,6 @@ import tachiyomi.presentation.core.util.plus
fun CategoryScreen(
state: CategoryScreenState.Success,
onClickCreate: () -> Unit,
onClickSortAlphabetically: () -> Unit,
onClickRename: (Category) -> Unit,
onClickDelete: (Category) -> Unit,
onChangeOrder: (Category, Int) -> Unit,
@ -53,17 +48,6 @@ fun CategoryScreen(
AppBar(
title = stringResource(MR.strings.action_edit_categories),
navigateUp = navigateUp,
actions = {
AppBarActions(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_sort),
icon = Icons.Outlined.SortByAlpha,
onClick = onClickSortAlphabetically,
),
),
)
},
scrollBehavior = scrollBehavior,
)
},

View file

@ -219,35 +219,6 @@ fun CategoryDeleteDialog(
)
}
@Composable
fun CategorySortAlphabeticallyDialog(
onDismissRequest: () -> Unit,
onSort: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismissRequest,
confirmButton = {
TextButton(onClick = {
onSort()
onDismissRequest()
}) {
Text(text = stringResource(MR.strings.action_ok))
}
},
dismissButton = {
TextButton(onClick = onDismissRequest) {
Text(text = stringResource(MR.strings.action_cancel))
}
},
title = {
Text(text = stringResource(MR.strings.action_sort_category))
},
text = {
Text(text = stringResource(MR.strings.sort_category_confirmation))
},
)
}
@Composable
fun ChangeCategoryDialog(
initialSelection: ImmutableList<CheckboxState<Category>>,

View file

@ -45,7 +45,6 @@ import tachiyomi.domain.source.interactor.GetSavedSearchGlobalFeed
import tachiyomi.domain.source.interactor.InsertFeedSavedSearch
import tachiyomi.domain.source.interactor.ReorderFeed
import tachiyomi.domain.source.model.FeedSavedSearch
import tachiyomi.domain.source.model.FeedSavedSearchUpdate
import tachiyomi.domain.source.model.SavedSearch
import tachiyomi.domain.source.service.SourceManager
import uy.kohesive.injekt.Injekt
@ -223,21 +222,6 @@ open class FeedScreenModel(
reorderFeed.changeOrder(feed, newIndex)
}
}
fun sortAlphabetically() {
screenModelScope.launch {
reorderFeed.sortAlphabetically(
state.value.items
?.sortedBy { feed -> feed.title }
?.mapIndexed { index, feed ->
FeedSavedSearchUpdate(
id = feed.feed.id,
feedOrder = index.toLong(),
)
},
)
}
}
// KMK <--
private suspend fun getSourcesToGetFeed(feedSavedSearch: List<FeedSavedSearch>): List<Pair<FeedSavedSearch, SavedSearch?>> {
@ -384,8 +368,6 @@ open class FeedScreenModel(
data class FeedActions(
val feedItem: FeedItemUI,
) : Dialog()
data object SortAlphabetically : Dialog()
// KMK <--
}

View file

@ -4,7 +4,7 @@ import androidx.activity.compose.BackHandler
import androidx.compose.animation.Crossfade
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.SortByAlpha
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material.icons.outlined.SwapVert
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
@ -24,7 +24,6 @@ import eu.kanade.presentation.browse.FeedAddSearchDialog
import eu.kanade.presentation.browse.FeedOrderScreen
import eu.kanade.presentation.browse.FeedScreen
import eu.kanade.presentation.browse.components.FeedActionsDialog
import eu.kanade.presentation.browse.components.FeedSortAlphabeticallyDialog
import eu.kanade.presentation.browse.components.SourceFeedDeleteDialog
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.TabContent
@ -99,15 +98,10 @@ fun feedTab(
persistentListOf(
AppBar.Action(
title = stringResource(KMR.strings.action_sort_feed),
icon = Icons.Outlined.SwapVert,
icon = Icons.Outlined.Close,
iconTint = MaterialTheme.colorScheme.primary,
onClick = { showingFeedOrderScreen.value = false },
),
AppBar.Action(
title = stringResource(MR.strings.action_sort),
icon = Icons.Outlined.SortByAlpha,
onClick = { screenModel.showDialog(FeedScreenModel.Dialog.SortAlphabetically) },
),
)
} else {
// KMK <--
@ -252,12 +246,6 @@ fun feedTab(
onClickDelete = { screenModel.openDeleteDialog(it) },
)
}
is FeedScreenModel.Dialog.SortAlphabetically -> {
FeedSortAlphabeticallyDialog(
onDismissRequest = onDismissRequest,
onSort = { screenModel.sortAlphabetically() },
)
}
// KMK <--
}
}

View file

@ -22,7 +22,6 @@ import eu.kanade.presentation.browse.SourceFeedOrderScreen
import eu.kanade.presentation.browse.SourceFeedScreen
import eu.kanade.presentation.browse.SourceFeedUI
import eu.kanade.presentation.browse.components.FeedActionsDialog
import eu.kanade.presentation.browse.components.FeedSortAlphabeticallyDialog
import eu.kanade.presentation.browse.components.SourceFeedAddDialog
import eu.kanade.presentation.browse.components.SourceFeedDeleteDialog
import eu.kanade.presentation.util.Screen
@ -106,9 +105,6 @@ class SourceFeedScreen(val sourceId: Long) : Screen() {
state = state,
onClickDelete = screenModel::openDeleteFeed,
onChangeOrder = screenModel::changeOrder,
onClickSortAlphabetically = {
screenModel.showDialog(SourceFeedScreenModel.Dialog.SortAlphabetically)
},
navigateUp = { showingFeedOrderScreen.value = false },
)
} else {
@ -224,12 +220,6 @@ class SourceFeedScreen(val sourceId: Long) : Screen() {
onClickDelete = { screenModel.openDeleteFeed(it) },
)
}
is SourceFeedScreenModel.Dialog.SortAlphabetically -> {
FeedSortAlphabeticallyDialog(
onDismissRequest = screenModel::dismissDialog,
onSort = { screenModel.sortAlphabetically() },
)
}
// KMK <--
is SourceFeedScreenModel.Dialog.Filter -> {
SourceFilterDialog(

View file

@ -48,7 +48,6 @@ import tachiyomi.domain.source.interactor.InsertFeedSavedSearch
import tachiyomi.domain.source.interactor.ReorderFeed
import tachiyomi.domain.source.model.EXHSavedSearch
import tachiyomi.domain.source.model.FeedSavedSearch
import tachiyomi.domain.source.model.FeedSavedSearchUpdate
import tachiyomi.domain.source.model.SavedSearch
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.i18n.kmk.KMR
@ -160,22 +159,6 @@ open class SourceFeedScreenModel(
reorderFeed.changeOrder(feed, newIndex, false)
}
}
fun sortAlphabetically() {
screenModelScope.launchNonCancellable {
reorderFeed.sortAlphabetically(
state.value.items
.filterIsInstance<SourceFeedUI.SourceSavedSearch>()
.sortedBy { feed -> feed.title }
.mapIndexed { index, feed ->
FeedSavedSearchUpdate(
id = feed.feed.id,
feedOrder = index.toLong(),
)
},
)
}
}
// KMK <--
private suspend fun getSourcesToGetFeed(feedSavedSearch: List<FeedSavedSearch>): ImmutableList<SourceFeedUI> {
@ -422,8 +405,6 @@ open class SourceFeedScreenModel(
data class FeedActions(
val feedItem: SourceFeedUI.SourceSavedSearch,
) : Dialog()
data object SortAlphabetically : Dialog()
// KMK <--
}

View file

@ -13,7 +13,6 @@ import eu.kanade.presentation.category.CategoryScreen
import eu.kanade.presentation.category.components.CategoryCreateDialog
import eu.kanade.presentation.category.components.CategoryDeleteDialog
import eu.kanade.presentation.category.components.CategoryRenameDialog
import eu.kanade.presentation.category.components.CategorySortAlphabeticallyDialog
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.toImmutableList
@ -40,7 +39,6 @@ class CategoryScreen : Screen() {
CategoryScreen(
state = successState,
onClickCreate = { screenModel.showDialog(CategoryDialog.Create) },
onClickSortAlphabetically = { screenModel.showDialog(CategoryDialog.SortAlphabetically) },
onClickRename = { screenModel.showDialog(CategoryDialog.Rename(it)) },
onClickDelete = { screenModel.showDialog(CategoryDialog.Delete(it)) },
onChangeOrder = screenModel::changeOrder,
@ -74,12 +72,6 @@ class CategoryScreen : Screen() {
category = dialog.category.name,
)
}
is CategoryDialog.SortAlphabetically -> {
CategorySortAlphabeticallyDialog(
onDismissRequest = screenModel::dismissDialog,
onSort = { screenModel.sortAlphabetically() },
)
}
}
LaunchedEffect(Unit) {

View file

@ -80,18 +80,9 @@ class CategoryScreenModel(
}
}
fun sortAlphabetically() {
screenModelScope.launch {
when (reorderCategory.sortAlphabetically()) {
is ReorderCategory.Result.InternalError -> _events.send(CategoryEvent.InternalError)
else -> {}
}
}
}
fun changeOrder(category: Category, newIndex: Int) {
screenModelScope.launch {
when (reorderCategory.changeOrder(category, newIndex)) {
when (reorderCategory.await(category, newIndex)) {
is ReorderCategory.Result.InternalError -> _events.send(CategoryEvent.InternalError)
else -> {}
}
@ -128,7 +119,6 @@ class CategoryScreenModel(
sealed interface CategoryDialog {
data object Create : CategoryDialog
data object SortAlphabetically : CategoryDialog
data class Rename(val category: Category) : CategoryDialog
data class Delete(val category: Category) : CategoryDialog
}

View file

@ -12,10 +12,9 @@ import tachiyomi.domain.category.repository.CategoryRepository
class ReorderCategory(
private val categoryRepository: CategoryRepository,
) {
private val mutex = Mutex()
suspend fun changeOrder(category: Category, newIndex: Int) = withNonCancellableContext {
suspend fun await(category: Category, newIndex: Int) = withNonCancellableContext {
mutex.withLock {
val categories = categoryRepository.getAll()
.filterNot(Category::isSystemCategory)
@ -45,27 +44,6 @@ class ReorderCategory(
}
}
suspend fun sortAlphabetically() = withNonCancellableContext {
mutex.withLock {
val updates = categoryRepository.getAll()
.sortedBy { category -> category.name }
.mapIndexed { index, category ->
CategoryUpdate(
id = category.id,
order = index.toLong(),
)
}
try {
categoryRepository.updatePartial(updates)
Result.Success
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
Result.InternalError(e)
}
}
}
sealed interface Result {
data object Success : Result
data object Unchanged : Result

View file

@ -49,19 +49,6 @@ class ReorderFeed(
}
}
suspend fun sortAlphabetically(updates: List<FeedSavedSearchUpdate>?) = withNonCancellableContext {
if (updates == null) return@withNonCancellableContext
mutex.withLock {
try {
feedSavedSearchRepository.updatePartial(updates)
Result.Success
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
Result.InternalError(e)
}
}
}
sealed interface Result {
data object Success : Result
data object Unchanged : Result

View file

@ -97,8 +97,6 @@
<string name="action_move_category">Set categories</string>
<string name="delete_category_confirmation">Do you wish to delete the category \"%s\"?</string>
<string name="delete_category">Delete category</string>
<string name="action_sort_category">Sort categories</string>
<string name="sort_category_confirmation">Would you like to sort the categories alphabetically?</string>
<string name="action_edit_cover">Edit cover</string>
<string name="action_view_chapters">View chapters</string>
<string name="action_pause">Pause</string>