mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 21:47:28 +01:00
Add ability to open random manga (#8232)
* Add ability to open random manga * Use `getMangaForCategory` instead * Put it in overflow menu instead of using EFAB * Partial review changes * Merge remote-tracking branch 'refs/remotes/origin/patch-6' into patch-6 # Conflicts: # app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt * Merge remote-tracking branch 'refs/remotes/origin/patch-6' into patch-6 # Conflicts: # app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt * Wording changes
This commit is contained in:
@@ -43,6 +43,8 @@ class LibraryController(
|
||||
@Composable
|
||||
override fun ComposeContent() {
|
||||
val context = LocalContext.current
|
||||
val getMangaForCategory = presenter.getMangaForCategory(page = presenter.activeCategory)
|
||||
|
||||
LibraryScreen(
|
||||
presenter = presenter,
|
||||
onMangaClicked = ::openManga,
|
||||
@@ -60,6 +62,14 @@ class LibraryController(
|
||||
context.toast(if (started) R.string.updating_category else R.string.update_already_running)
|
||||
started
|
||||
},
|
||||
onClickOpenRandomManga = {
|
||||
val items = getMangaForCategory.map { it.libraryManga.manga.id }
|
||||
if (getMangaForCategory.isNotEmpty()) {
|
||||
openManga(items.random())
|
||||
} else {
|
||||
context.toast(R.string.information_no_entries_found)
|
||||
}
|
||||
},
|
||||
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
|
||||
onClickSelectAll = { presenter.selectAll(presenter.activeCategory) },
|
||||
onClickUnselectAll = ::clearSelection,
|
||||
|
||||
@@ -526,7 +526,7 @@ class LibraryPresenter(
|
||||
|
||||
@Composable
|
||||
fun getMangaForCategory(page: Int): List<LibraryItem> {
|
||||
val unfiltered = remember(categories, loadedManga) {
|
||||
val unfiltered = remember(categories, loadedManga, page) {
|
||||
val categoryId = categories.getOrNull(page)?.id ?: -1
|
||||
loadedManga[categoryId] ?: emptyList()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user