Fixes for merged manga settings
This commit is contained in:
parent
5afc33becb
commit
1acb7a1a35
@ -68,6 +68,7 @@ class MangaMergeRepositoryImpl(
|
||||
downloadChapters = value.downloadChapters?.toLong(),
|
||||
infoManga = value.isInfoManga?.toLong(),
|
||||
chapterPriority = value.chapterPriority?.toLong(),
|
||||
chapterSortMode = value.chapterSortMode?.toLong(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import eu.kanade.tachiyomi.util.system.logcat
|
||||
import exh.merged.sql.models.MergedMangaReference
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.flow.map
|
||||
import logcat.LogPriority
|
||||
|
||||
class GetMergedChapterByMangaId(
|
||||
@ -19,14 +19,14 @@ class GetMergedChapterByMangaId(
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, editScanlators: Boolean = false, dedupe: Boolean = true): List<Chapter> {
|
||||
return transformMergedChapters(mangaId, getFromDatabase(mangaId), editScanlators, dedupe)
|
||||
return transformMergedChapters(getMergedReferencesById.await(mangaId), getFromDatabase(mangaId), editScanlators, dedupe)
|
||||
}
|
||||
|
||||
suspend fun subscribe(mangaId: Long, editScanlators: Boolean = false, dedupe: Boolean = true): Flow<List<Chapter>> {
|
||||
return try {
|
||||
chapterRepository.getMergedChapterByMangaIdAsFlow(mangaId)
|
||||
.map {
|
||||
transformMergedChapters(mangaId, it, editScanlators, dedupe)
|
||||
.combine(getMergedReferencesById.subscribe(mangaId)) { chapters, references ->
|
||||
transformMergedChapters(references, chapters, editScanlators, dedupe)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
@ -44,8 +44,7 @@ class GetMergedChapterByMangaId(
|
||||
}
|
||||
|
||||
// TODO more chapter dedupe
|
||||
suspend fun transformMergedChapters(mangaId: Long, chapterList: List<Chapter>, editScanlators: Boolean, dedupe: Boolean): List<Chapter> {
|
||||
val mangaReferences = getMergedReferencesById.await(mangaId)
|
||||
fun transformMergedChapters(mangaReferences: List<MergedMangaReference>, chapterList: List<Chapter>, editScanlators: Boolean, dedupe: Boolean): List<Chapter> {
|
||||
val chapters = if (editScanlators) {
|
||||
val sources = mangaReferences.map { sourceManager.getOrStub(it.mangaSourceId) to it.mangaId }
|
||||
chapterList.map { chapter ->
|
||||
|
@ -6,4 +6,5 @@ data class MergeMangaSettingsUpdate(
|
||||
var getChapterUpdates: Boolean?,
|
||||
var chapterPriority: Int?,
|
||||
var downloadChapters: Boolean?,
|
||||
var chapterSortMode: Int?,
|
||||
)
|
||||
|
@ -654,11 +654,12 @@ class MangaInfoScreenModel(
|
||||
updateMergedSettings.awaitAll(
|
||||
mergedMangaReferences.map {
|
||||
MergeMangaSettingsUpdate(
|
||||
it.id!!,
|
||||
it.isInfoManga,
|
||||
it.getChapterUpdates,
|
||||
it.chapterPriority,
|
||||
it.downloadChapters,
|
||||
id = it.id!!,
|
||||
isInfoManga = it.isInfoManga,
|
||||
getChapterUpdates = it.getChapterUpdates,
|
||||
chapterPriority = it.chapterPriority,
|
||||
downloadChapters = it.downloadChapters,
|
||||
chapterSortMode = it.chapterSortMode,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
@ -66,7 +66,7 @@ class EditMergedSettingsState(
|
||||
|
||||
mergedMangaAdapter?.isHandleDragEnabled = isPriorityOrder
|
||||
|
||||
mergedMangaAdapter?.updateDataSet(mergedMangas.map { it.toModel() })
|
||||
mergedMangaAdapter?.updateDataSet(mergedMangas.map { it.toModel() }.sortedBy { it.mergedMangaReference.chapterPriority })
|
||||
}
|
||||
|
||||
override fun onItemReleased(position: Int) {
|
||||
@ -143,6 +143,7 @@ class EditMergedSettingsState(
|
||||
|
||||
fun onPositiveButtonClick() {
|
||||
onPositiveClick(listOfNotNull(mergeReference) + mergedMangas.map { it.second })
|
||||
onDismissRequest()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,8 @@ SET
|
||||
get_chapter_updates = coalesce(:getChapterUpdates, get_chapter_updates),
|
||||
download_chapters = coalesce(:downloadChapters, download_chapters),
|
||||
info_manga = coalesce(:infoManga, info_manga),
|
||||
chapter_priority = coalesce(:chapterPriority, chapter_priority)
|
||||
chapter_priority = coalesce(:chapterPriority, chapter_priority),
|
||||
chapter_sort_mode = coalesce(:chapterSortMode, chapter_sort_mode)
|
||||
WHERE _id = :id;
|
||||
|
||||
deleteById:
|
||||
|
Loading…
x
Reference in New Issue
Block a user