Fix crash opening filter sheet with empty library and mark as read/unread for selected items (mihonapp/mihon#2355)
(cherry picked from commit d88dbe6409b9c4dd7fbb37757e89c09af73f1fd3)
This commit is contained in:
parent
395f68f71f
commit
639459f8af
2 changed files with 10 additions and 6 deletions
|
|
@ -22,6 +22,8 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
- Fix local source EPUB files not loading ([@AntsyLich](https://github.com/AntsyLich)) ([#2369](https://github.com/mihonapp/mihon/pull/2369))
|
- Fix local source EPUB files not loading ([@AntsyLich](https://github.com/AntsyLich)) ([#2369](https://github.com/mihonapp/mihon/pull/2369))
|
||||||
- Fix title text color in light mode on mass migration list ([@AntsyLich](https://github.com/AntsyLich)) ([#2370](https://github.com/mihonapp/mihon/pull/2370))
|
- Fix title text color in light mode on mass migration list ([@AntsyLich](https://github.com/AntsyLich)) ([#2370](https://github.com/mihonapp/mihon/pull/2370))
|
||||||
- Fix 'Default' category showing in library with no user-added categories ([@AntsyLich](https://github.com/AntsyLich)) ([#2371](https://github.com/mihonapp/mihon/pull/2371))
|
- Fix 'Default' category showing in library with no user-added categories ([@AntsyLich](https://github.com/AntsyLich)) ([#2371](https://github.com/mihonapp/mihon/pull/2371))
|
||||||
|
- Fix crash when opening filter sheet with an empty library ([@krysanify](https://github.com/krysanify/)) ([#2355](https://github.com/mihonapp/mihon/pull/2355))
|
||||||
|
- Fix mark as read/unread not working for selected library items ([@krysanify](https://github.com/krysanify/)) ([#2355](https://github.com/mihonapp/mihon/pull/2355))
|
||||||
|
|
||||||
## [v0.19.0] - 2025-08-04
|
## [v0.19.0] - 2025-08-04
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -1006,8 +1006,9 @@ class LibraryScreenModel(
|
||||||
* Marks mangas' chapters read status.
|
* Marks mangas' chapters read status.
|
||||||
*/
|
*/
|
||||||
fun markReadSelection(read: Boolean) {
|
fun markReadSelection(read: Boolean) {
|
||||||
|
val selection = state.value.selectedManga
|
||||||
screenModelScope.launchNonCancellable {
|
screenModelScope.launchNonCancellable {
|
||||||
state.value.selectedManga.forEach { manga ->
|
selection.forEach { manga ->
|
||||||
setReadStatus.await(
|
setReadStatus.await(
|
||||||
manga = manga,
|
manga = manga,
|
||||||
read = read,
|
read = read,
|
||||||
|
|
@ -1094,7 +1095,7 @@ class LibraryScreenModel(
|
||||||
|
|
||||||
fun getRandomLibraryItemForCurrentCategory(): LibraryItem? {
|
fun getRandomLibraryItemForCurrentCategory(): LibraryItem? {
|
||||||
val state = state.value
|
val state = state.value
|
||||||
return state.getItemsForCategoryId(state.activeCategory.id).randomOrNull()
|
return state.getItemsForCategoryId(state.activeCategory?.id).randomOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showSettingsDialog() {
|
fun showSettingsDialog() {
|
||||||
|
|
@ -1325,7 +1326,7 @@ class LibraryScreenModel(
|
||||||
lastSelectionCategory = null
|
lastSelectionCategory = null
|
||||||
mutableState.update { state ->
|
mutableState.update { state ->
|
||||||
val newSelection = state.selection.mutate { list ->
|
val newSelection = state.selection.mutate { list ->
|
||||||
state.getItemsForCategoryId(state.activeCategory.id).map { it.id }.let(list::addAll)
|
state.getItemsForCategoryId(state.activeCategory?.id).map { it.id }.let(list::addAll)
|
||||||
}
|
}
|
||||||
state.copy(selection = newSelection)
|
state.copy(selection = newSelection)
|
||||||
}
|
}
|
||||||
|
|
@ -1335,7 +1336,7 @@ class LibraryScreenModel(
|
||||||
lastSelectionCategory = null
|
lastSelectionCategory = null
|
||||||
mutableState.update { state ->
|
mutableState.update { state ->
|
||||||
val newSelection = state.selection.mutate { list ->
|
val newSelection = state.selection.mutate { list ->
|
||||||
val itemIds = state.getItemsForCategoryId(state.activeCategory.id).fastMap { it.id }
|
val itemIds = state.getItemsForCategoryId(state.activeCategory?.id).fastMap { it.id }
|
||||||
val (toRemove, toAdd) = itemIds.partition { it in list }
|
val (toRemove, toAdd) = itemIds.partition { it in list }
|
||||||
list.removeAll(toRemove.toSet())
|
list.removeAll(toRemove.toSet())
|
||||||
list.addAll(toAdd)
|
list.addAll(toAdd)
|
||||||
|
|
@ -1640,7 +1641,7 @@ class LibraryScreenModel(
|
||||||
maximumValue = displayedCategories.lastIndex.coerceAtLeast(0),
|
maximumValue = displayedCategories.lastIndex.coerceAtLeast(0),
|
||||||
)
|
)
|
||||||
|
|
||||||
val activeCategory: Category by lazy { displayedCategories[coercedActiveCategoryIndex] }
|
val activeCategory: Category? = displayedCategories.getOrNull(coercedActiveCategoryIndex)
|
||||||
|
|
||||||
val isLibraryEmpty = libraryData.favorites.isEmpty()
|
val isLibraryEmpty = libraryData.favorites.isEmpty()
|
||||||
|
|
||||||
|
|
@ -1673,7 +1674,8 @@ class LibraryScreenModel(
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
fun getItemsForCategoryId(categoryId: Long): List<LibraryItem> {
|
fun getItemsForCategoryId(categoryId: Long?): List<LibraryItem> {
|
||||||
|
if (categoryId == null) return emptyList()
|
||||||
val category = displayedCategories.find { it.id == categoryId } ?: return emptyList()
|
val category = displayedCategories.find { it.id == categoryId } ?: return emptyList()
|
||||||
return getItemsForCategory(category)
|
return getItemsForCategory(category)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue