mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Some clean up
This commit is contained in:
parent
ec36c9faf7
commit
19b1ba76c7
1 changed files with 5 additions and 52 deletions
|
@ -198,15 +198,6 @@ class LibraryPresenter(
|
||||||
lastAllLibraryItems = null
|
lastAllLibraryItems = null
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
presenterScope.launch {
|
|
||||||
getLibraryManga.subscribe().collectLatest {
|
|
||||||
libraryManga = it.apply { if (groupType > BY_DEFAULT) { distinctBy { it.id } } }
|
|
||||||
getLibrary()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
subscribeLibrary()
|
subscribeLibrary()
|
||||||
|
|
||||||
if (!preferences.showLibrarySearchSuggestions().isSet()) {
|
if (!preferences.showLibrarySearchSuggestions().isSet()) {
|
||||||
|
@ -272,7 +263,6 @@ class LibraryPresenter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Remove this, it's useless
|
|
||||||
/** Get favorited manga for library and sort and filter it */
|
/** Get favorited manga for library and sort and filter it */
|
||||||
fun getLibrary() {
|
fun getLibrary() {
|
||||||
presenterScope.launch {
|
presenterScope.launch {
|
||||||
|
@ -825,11 +815,10 @@ class LibraryPresenter(
|
||||||
getLibraryManga.subscribe(),
|
getLibraryManga.subscribe(),
|
||||||
getPreferencesFlow(),
|
getPreferencesFlow(),
|
||||||
preferences.removeArticles().changes(),
|
preferences.removeArticles().changes(),
|
||||||
fetchLibrary,
|
) { allCategories, libraryMangaList, prefs, removeArticles ->
|
||||||
) { allCategories, libraryMangaList, prefs, removeArticles, _ ->
|
|
||||||
groupType = prefs.groupType
|
groupType = prefs.groupType
|
||||||
|
|
||||||
val data = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
|
val (items, categories, hiddenItems) = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
|
||||||
getLibraryItems(
|
getLibraryItems(
|
||||||
allCategories,
|
allCategories,
|
||||||
libraryMangaList,
|
libraryMangaList,
|
||||||
|
@ -847,51 +836,15 @@ class LibraryPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryData(
|
LibraryData(
|
||||||
categories = data.second,
|
categories = categories,
|
||||||
allCategories = allCategories,
|
allCategories = allCategories,
|
||||||
items = data.first,
|
items = items,
|
||||||
hiddenItems = data.third,
|
hiddenItems = hiddenItems,
|
||||||
removeArticles = removeArticles,
|
removeArticles = removeArticles,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the categories and all its manga from the database.
|
|
||||||
*
|
|
||||||
* @return an list of all the manga in a itemized form.
|
|
||||||
*/
|
|
||||||
private suspend fun getLibraryFromDB(): Pair<List<LibraryItem>, List<LibraryItem>> {
|
|
||||||
removeArticles = preferences.removeArticles().get()
|
|
||||||
allCategories = getCategories.await().toMutableList()
|
|
||||||
|
|
||||||
// In default grouping, which uses category as group, a manga can be in multiple categories.
|
|
||||||
// So before we group it by different type, we should make the list unique.
|
|
||||||
val libraryManga = getLibraryManga.await()
|
|
||||||
val showAll = showAllCategories
|
|
||||||
|
|
||||||
val (items, categories, hiddenItems) = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
|
|
||||||
getLibraryItems(
|
|
||||||
allCategories,
|
|
||||||
libraryManga,
|
|
||||||
preferences.librarySortingMode().get(),
|
|
||||||
preferences.librarySortingAscending().get(),
|
|
||||||
showAll,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
getDynamicLibraryItems(
|
|
||||||
libraryManga,
|
|
||||||
preferences.librarySortingMode().get(),
|
|
||||||
preferences.librarySortingAscending().get(),
|
|
||||||
groupType,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.categories = categories
|
|
||||||
|
|
||||||
return items to hiddenItems
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getLibraryItems(
|
private fun getLibraryItems(
|
||||||
allCategories: List<Category>,
|
allCategories: List<Category>,
|
||||||
libraryManga: List<LibraryManga>,
|
libraryManga: List<LibraryManga>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue