|
@@ -22,6 +22,7 @@ import eu.kanade.core.prefs.mapAsCheckboxState
|
|
|
import eu.kanade.domain.base.BasePreferences
|
|
|
import eu.kanade.domain.category.interactor.GetCategories
|
|
|
import eu.kanade.domain.category.interactor.SetMangaCategories
|
|
|
+import eu.kanade.domain.category.model.Category
|
|
|
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
|
|
import eu.kanade.domain.chapter.interactor.SetMangaDefaultChapterFlags
|
|
|
import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay
|
|
@@ -30,6 +31,7 @@ import eu.kanade.domain.manga.interactor.GetDuplicateLibraryManga
|
|
|
import eu.kanade.domain.manga.interactor.GetManga
|
|
|
import eu.kanade.domain.manga.interactor.NetworkToLocalManga
|
|
|
import eu.kanade.domain.manga.interactor.UpdateManga
|
|
|
+import eu.kanade.domain.manga.model.Manga
|
|
|
import eu.kanade.domain.manga.model.toDbManga
|
|
|
import eu.kanade.domain.manga.model.toDomainManga
|
|
|
import eu.kanade.domain.manga.model.toMangaUpdate
|
|
@@ -76,8 +78,6 @@ import logcat.LogPriority
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
import uy.kohesive.injekt.api.get
|
|
|
import java.util.Date
|
|
|
-import eu.kanade.domain.category.model.Category as DomainCategory
|
|
|
-import eu.kanade.domain.manga.model.Manga as DomainManga
|
|
|
|
|
|
open class BrowseSourcePresenter(
|
|
|
private val sourceId: Long,
|
|
@@ -121,7 +121,7 @@ open class BrowseSourcePresenter(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
- fun getMangaList(): Flow<PagingData<DomainManga>> {
|
|
|
+ fun getMangaList(): Flow<PagingData<Manga>> {
|
|
|
return remember(currentFilter) {
|
|
|
Pager(
|
|
|
PagingConfig(pageSize = 25),
|
|
@@ -140,7 +140,7 @@ open class BrowseSourcePresenter(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
- fun getManga(initialManga: DomainManga): State<DomainManga> {
|
|
|
+ fun getManga(initialManga: Manga): State<Manga> {
|
|
|
return produceState(initialValue = initialManga) {
|
|
|
getManga.subscribe(initialManga.url, initialManga.source)
|
|
|
.collectLatest { manga ->
|
|
@@ -186,7 +186,7 @@ open class BrowseSourcePresenter(
|
|
|
*
|
|
|
* @param manga to initialize.
|
|
|
*/
|
|
|
- private suspend fun initializeManga(manga: DomainManga) {
|
|
|
+ private suspend fun initializeManga(manga: Manga) {
|
|
|
if (manga.thumbnailUrl != null || manga.initialized) return
|
|
|
withNonCancellableContext {
|
|
|
try {
|
|
@@ -206,7 +206,7 @@ open class BrowseSourcePresenter(
|
|
|
*
|
|
|
* @param manga the manga to update.
|
|
|
*/
|
|
|
- fun changeMangaFavorite(manga: DomainManga) {
|
|
|
+ fun changeMangaFavorite(manga: Manga) {
|
|
|
presenterScope.launch {
|
|
|
var new = manga.copy(
|
|
|
favorite = !manga.favorite,
|
|
@@ -228,11 +228,11 @@ open class BrowseSourcePresenter(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fun getSourceOrStub(manga: DomainManga): Source {
|
|
|
+ fun getSourceOrStub(manga: Manga): Source {
|
|
|
return sourceManager.getOrStub(manga.source)
|
|
|
}
|
|
|
|
|
|
- fun addFavorite(manga: DomainManga) {
|
|
|
+ fun addFavorite(manga: Manga) {
|
|
|
presenterScope.launch {
|
|
|
val categories = getCategories()
|
|
|
val defaultCategoryId = libraryPreferences.defaultCategory().get()
|
|
@@ -262,7 +262,7 @@ open class BrowseSourcePresenter(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private suspend fun autoAddTrack(manga: DomainManga) {
|
|
|
+ private suspend fun autoAddTrack(manga: Manga) {
|
|
|
loggedServices
|
|
|
.filterIsInstance<EnhancedTrackService>()
|
|
|
.filter { it.accept(source!!) }
|
|
@@ -287,22 +287,22 @@ open class BrowseSourcePresenter(
|
|
|
*
|
|
|
* @return List of categories, not including the default category
|
|
|
*/
|
|
|
- suspend fun getCategories(): List<DomainCategory> {
|
|
|
+ suspend fun getCategories(): List<Category> {
|
|
|
return getCategories.subscribe()
|
|
|
.firstOrNull()
|
|
|
?.filterNot { it.isSystemCategory }
|
|
|
?: emptyList()
|
|
|
}
|
|
|
|
|
|
- suspend fun getDuplicateLibraryManga(manga: DomainManga): DomainManga? {
|
|
|
+ suspend fun getDuplicateLibraryManga(manga: Manga): Manga? {
|
|
|
return getDuplicateLibraryManga.await(manga.title, manga.source)
|
|
|
}
|
|
|
|
|
|
- fun moveMangaToCategories(manga: DomainManga, vararg categories: DomainCategory) {
|
|
|
+ fun moveMangaToCategories(manga: Manga, vararg categories: Category) {
|
|
|
moveMangaToCategories(manga, categories.filter { it.id != 0L }.map { it.id })
|
|
|
}
|
|
|
|
|
|
- fun moveMangaToCategories(manga: DomainManga, categoryIds: List<Long>) {
|
|
|
+ fun moveMangaToCategories(manga: Manga, categoryIds: List<Long>) {
|
|
|
presenterScope.launchIO {
|
|
|
setMangaCategories.await(
|
|
|
mangaId = manga.id,
|
|
@@ -328,11 +328,11 @@ open class BrowseSourcePresenter(
|
|
|
}
|
|
|
|
|
|
sealed class Dialog {
|
|
|
- data class RemoveManga(val manga: DomainManga) : Dialog()
|
|
|
- data class AddDuplicateManga(val manga: DomainManga, val duplicate: DomainManga) : Dialog()
|
|
|
+ data class RemoveManga(val manga: Manga) : Dialog()
|
|
|
+ data class AddDuplicateManga(val manga: Manga, val duplicate: Manga) : Dialog()
|
|
|
data class ChangeMangaCategory(
|
|
|
- val manga: DomainManga,
|
|
|
- val initialSelection: List<CheckboxState.State<DomainCategory>>,
|
|
|
+ val manga: Manga,
|
|
|
+ val initialSelection: List<CheckboxState.State<Category>>,
|
|
|
) : Dialog()
|
|
|
}
|
|
|
}
|