mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
More domain model usage
This commit is contained in:
@@ -2,7 +2,8 @@ package eu.kanade.tachiyomi.util.chapter
|
||||
|
||||
import eu.kanade.domain.manga.interactor.GetFavorites
|
||||
import eu.kanade.domain.manga.interactor.SetMangaChapterFlags
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.domain.manga.model.Manga
|
||||
import eu.kanade.domain.manga.model.toDbManga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@@ -17,7 +18,7 @@ object ChapterSettingsHelper {
|
||||
* Updates the global Chapter Settings in Preferences.
|
||||
*/
|
||||
fun setGlobalSettings(manga: Manga) {
|
||||
prefs.setChapterSettingsDefault(manga)
|
||||
prefs.setChapterSettingsDefault(manga.toDbManga())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ object ChapterSettingsHelper {
|
||||
fun applySettingDefaults(manga: Manga) {
|
||||
launchIO {
|
||||
setMangaChapterFlags.awaitSetAllFlags(
|
||||
mangaId = manga.id!!,
|
||||
mangaId = manga.id,
|
||||
unreadFilter = prefs.filterChapterByRead().toLong(),
|
||||
downloadedFilter = prefs.filterChapterByDownloaded().toLong(),
|
||||
bookmarkedFilter = prefs.filterChapterByBookmarked().toLong(),
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package eu.kanade.tachiyomi.util.chapter
|
||||
|
||||
import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource
|
||||
import eu.kanade.domain.chapter.model.toDbChapter
|
||||
import eu.kanade.tachiyomi.data.database.models.toDomainManga
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter as DbChapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga as DbManga
|
||||
|
||||
/**
|
||||
* Helper method for syncing the list of chapters from the source with the ones from the database.
|
||||
*
|
||||
* @param rawSourceChapters a list of chapters from the source.
|
||||
* @param manga the manga of the chapters.
|
||||
* @param source the source of the chapters.
|
||||
* @return a pair of new insertions and deletions.
|
||||
*/
|
||||
suspend fun syncChaptersWithSource(
|
||||
rawSourceChapters: List<SChapter>,
|
||||
manga: DbManga,
|
||||
source: Source,
|
||||
syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(),
|
||||
): Pair<List<DbChapter>, List<DbChapter>> {
|
||||
val domainManga = manga.toDomainManga() ?: return Pair(emptyList(), emptyList())
|
||||
val (added, deleted) = syncChaptersWithSource.await(rawSourceChapters, domainManga, source)
|
||||
|
||||
val addedDbChapters = added.map { it.toDbChapter() }
|
||||
val deletedDbChapters = deleted.map { it.toDbChapter() }
|
||||
|
||||
return Pair(addedDbChapters, deletedDbChapters)
|
||||
}
|
||||
Reference in New Issue
Block a user