Merge 1c202920be03b909a1a9b523a563d4146562bbb0 into 40fe5f8437172a82fd29ef702707e67d45d85dcf

This commit is contained in:
Cuong-Tran 2024-12-06 16:38:40 -04:00 committed by GitHub
commit 4daa425122
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.update
import tachiyomi.core.common.util.lang.launchIO import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.domain.chapter.interactor.GetChapterByUrlAndMangaId import tachiyomi.domain.chapter.interactor.GetChapterByUrlAndMangaId
import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.interactor.GetMangaByUrlAndSourceId
import tachiyomi.domain.manga.interactor.NetworkToLocalManga import tachiyomi.domain.manga.interactor.NetworkToLocalManga
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.service.SourceManager import tachiyomi.domain.source.service.SourceManager
@ -27,7 +26,6 @@ class DeepLinkScreenModel(
private val sourceManager: SourceManager = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(),
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(), private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
private val getChapterByUrlAndMangaId: GetChapterByUrlAndMangaId = Injekt.get(), private val getChapterByUrlAndMangaId: GetChapterByUrlAndMangaId = Injekt.get(),
private val getMangaByUrlAndSourceId: GetMangaByUrlAndSourceId = Injekt.get(),
private val syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(), private val syncChaptersWithSource: SyncChaptersWithSource = Injekt.get(),
) : StateScreenModel<DeepLinkScreenModel.State>(State.Loading) { ) : StateScreenModel<DeepLinkScreenModel.State>(State.Loading) {
@ -74,8 +72,7 @@ class DeepLinkScreenModel(
} }
private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga { private suspend fun getMangaFromSManga(sManga: SManga, sourceId: Long): Manga {
return getMangaByUrlAndSourceId.await(sManga.url, sourceId) return networkToLocalManga.await(sManga.toDomainManga(sourceId))
?: networkToLocalManga.await(sManga.toDomainManga(sourceId))
} }
sealed interface State { sealed interface State {

View File

@ -1,6 +1,7 @@
package tachiyomi.domain.manga.interactor package tachiyomi.domain.manga.interactor
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.manga.model.toMangaUpdate
import tachiyomi.domain.manga.repository.MangaRepository import tachiyomi.domain.manga.repository.MangaRepository
class NetworkToLocalManga( class NetworkToLocalManga(
@ -15,9 +16,21 @@ class NetworkToLocalManga(
manga.copy(id = id!!) manga.copy(id = id!!)
} }
!localManga.favorite -> { !localManga.favorite -> {
// if the manga isn't a favorite, set its display title from source // if the manga isn't a favorite, update new info from source to db
// if it later becomes a favorite, updated title will go to db val newThumbnail = manga.thumbnailUrl?.takeUnless { it.isBlank() }
localManga.copy(title = manga.title) val mangaUpdate = if (manga.initialized) {
manga.toMangaUpdate().copy(
id = localManga.id,
thumbnailUrl = newThumbnail,
)
} else {
localManga.toMangaUpdate().copy(
title = manga.title,
thumbnailUrl = newThumbnail,
)
}
mangaRepository.update(mangaUpdate)
manga.copy(id = localManga.id)
} }
else -> { else -> {
localManga localManga