Remove redundant userSelected from selection methods (mihonapp-mihon#2976)

(cherry picked from commit 9867c160f781b52cd297f7b1202cc6963b375df0)
This commit is contained in:
Cuong-Tran 2026-02-20 21:22:05 +07:00
parent 4c21f019c0
commit a52609b549
4 changed files with 11 additions and 15 deletions

View file

@ -194,7 +194,7 @@ fun MangaScreen(
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit, onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
// Chapter selection // Chapter selection
onChapterSelected: (ChapterList.Item, Boolean, Boolean, Boolean) -> Unit, onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
onAllChapterSelected: (Boolean) -> Unit, onAllChapterSelected: (Boolean) -> Unit,
onInvertSelection: () -> Unit, onInvertSelection: () -> Unit,
@ -404,7 +404,7 @@ private fun MangaScreenSmallImpl(
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit, onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
// Chapter selection // Chapter selection
onChapterSelected: (ChapterList.Item, Boolean, Boolean, Boolean) -> Unit, onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
onAllChapterSelected: (Boolean) -> Unit, onAllChapterSelected: (Boolean) -> Unit,
onInvertSelection: () -> Unit, onInvertSelection: () -> Unit,
@ -868,7 +868,7 @@ private fun MangaScreenLargeImpl(
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit, onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
// Chapter selection // Chapter selection
onChapterSelected: (ChapterList.Item, Boolean, Boolean, Boolean) -> Unit, onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
onAllChapterSelected: (Boolean) -> Unit, onAllChapterSelected: (Boolean) -> Unit,
onInvertSelection: () -> Unit, onInvertSelection: () -> Unit,
@ -1307,7 +1307,7 @@ private fun LazyListScope.sharedChapterItems(
// SY <-- // SY <--
onChapterClicked: (Chapter) -> Unit, onChapterClicked: (Chapter) -> Unit,
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?, onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
onChapterSelected: (ChapterList.Item, Boolean, Boolean, Boolean) -> Unit, onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit, onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
) { ) {
items( items(
@ -1376,14 +1376,14 @@ private fun LazyListScope.sharedChapterItems(
chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeStartAction = chapterSwipeStartAction,
chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeEndAction = chapterSwipeEndAction,
onLongClick = { onLongClick = {
onChapterSelected(item, !item.selected, true, true) onChapterSelected(item, !item.selected, true)
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
}, },
onClick = { onClick = {
onChapterItemClick( onChapterItemClick(
chapterItem = item, chapterItem = item,
isAnyChapterSelected = isAnyChapterSelected, isAnyChapterSelected = isAnyChapterSelected,
onToggleSelection = { onChapterSelected(item, !item.selected, true, false) }, onToggleSelection = { onChapterSelected(item, !item.selected, false) },
onChapterClicked = onChapterClicked, onChapterClicked = onChapterClicked,
) )
}, },

View file

@ -171,7 +171,6 @@ internal fun LazyListScope.updatesUiItems(
// KMK --> // KMK -->
UpdateSelectionOptions( UpdateSelectionOptions(
selected = !updatesItem.selected, selected = !updatesItem.selected,
userSelected = true,
fromLongPress = true, fromLongPress = true,
isGroup = isLeader && item.isExpandable, isGroup = isLeader && item.isExpandable,
isExpanded = isExpanded, isExpanded = isExpanded,
@ -186,7 +185,6 @@ internal fun LazyListScope.updatesUiItems(
// KMK --> // KMK -->
UpdateSelectionOptions( UpdateSelectionOptions(
selected = !updatesItem.selected, selected = !updatesItem.selected,
userSelected = true,
fromLongPress = false, fromLongPress = false,
isGroup = isLeader && item.isExpandable, isGroup = isLeader && item.isExpandable,
isExpanded = isExpanded, isExpanded = isExpanded,

View file

@ -1725,7 +1725,6 @@ class MangaScreenModel(
fun toggleSelection( fun toggleSelection(
item: ChapterList.Item, item: ChapterList.Item,
selected: Boolean, selected: Boolean,
userSelected: Boolean = false,
fromLongPress: Boolean = false, fromLongPress: Boolean = false,
) { ) {
updateSuccessState { successState -> updateSuccessState { successState ->
@ -1741,7 +1740,7 @@ class MangaScreenModel(
set(selectedIndex, selectedItem.copy(selected = selected)) set(selectedIndex, selectedItem.copy(selected = selected))
selectedChapterIds.addOrRemove(item.id, selected) selectedChapterIds.addOrRemove(item.id, selected)
if (selected && userSelected && fromLongPress) { if (selected && fromLongPress) {
if (firstSelection) { if (firstSelection) {
selectedPositions[0] = selectedIndex selectedPositions[0] = selectedIndex
selectedPositions[1] = selectedIndex selectedPositions[1] = selectedIndex
@ -1767,7 +1766,7 @@ class MangaScreenModel(
} }
} }
} }
} else if (userSelected && !fromLongPress) { } else if (!fromLongPress) {
if (!selected) { if (!selected) {
if (selectedIndex == selectedPositions[0]) { if (selectedIndex == selectedPositions[0]) {
selectedPositions[0] = indexOfFirst { it.selected } selectedPositions[0] = indexOfFirst { it.selected }

View file

@ -362,7 +362,6 @@ class UpdatesScreenModel(
/** Bundles all of the boolean flags for updateselection into one type */ /** Bundles all of the boolean flags for updateselection into one type */
data class UpdateSelectionOptions( data class UpdateSelectionOptions(
val selected: Boolean, val selected: Boolean,
val userSelected: Boolean = false,
val fromLongPress: Boolean = false, val fromLongPress: Boolean = false,
val isGroup: Boolean = false, val isGroup: Boolean = false,
val isExpanded: Boolean = false, val isExpanded: Boolean = false,
@ -376,7 +375,7 @@ class UpdatesScreenModel(
// KMK <-- // KMK <--
) { ) {
// KMK --> // KMK -->
val (selected, userSelected, fromLongPress, isGroup, isExpanded) = selectionOptions val (selected, fromLongPress, isGroup, isExpanded) = selectionOptions
// KMK <-- // KMK <--
mutableState.update { state -> mutableState.update { state ->
// KMK --> // KMK -->
@ -410,7 +409,7 @@ class UpdatesScreenModel(
} }
// KMK <-- // KMK <--
if (selected && userSelected && fromLongPress) { if (selected && fromLongPress) {
if (firstSelection) { if (firstSelection) {
selectedPositions[0] = selectedIndex selectedPositions[0] = selectedIndex
selectedPositions[1] = selectedIndex selectedPositions[1] = selectedIndex
@ -436,7 +435,7 @@ class UpdatesScreenModel(
} }
} }
} }
} else if (userSelected && !fromLongPress) { } else if (!fromLongPress) {
if (!selected) { if (!selected) {
if (selectedIndex == selectedPositions[0]) { if (selectedIndex == selectedPositions[0]) {
selectedPositions[0] = indexOfFirst { it.selected } selectedPositions[0] = indexOfFirst { it.selected }