mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
Migrating manga now also saves more chapter info
Bookmarks, Last Read, Date fetched, and has been read fully (this was already tracked but previously it only took the highest chapters Closes #151
This commit is contained in:
parent
3977b2a67a
commit
ee4f3e6586
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.migration.manga.process
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.History
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
@ -110,16 +111,29 @@ class MigrationProcessAdapter(
|
|||||||
if (MigrationFlags.hasChapters(flags)) {
|
if (MigrationFlags.hasChapters(flags)) {
|
||||||
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
||||||
val maxChapterRead =
|
val maxChapterRead =
|
||||||
prevMangaChapters.filter { it.read }.maxBy { it.chapter_number }?.chapter_number
|
prevMangaChapters.filter { it.read }.maxOf { it.chapter_number }
|
||||||
if (maxChapterRead != null) {
|
|
||||||
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||||
|
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
||||||
|
val historyList = mutableListOf<History>()
|
||||||
for (chapter in dbChapters) {
|
for (chapter in dbChapters) {
|
||||||
if (chapter.isRecognizedNumber && chapter.chapter_number <= maxChapterRead) {
|
if (chapter.isRecognizedNumber) {
|
||||||
|
val prevChapter =
|
||||||
|
prevMangaChapters.find { it.isRecognizedNumber && it.chapter_number == chapter.chapter_number }
|
||||||
|
if (prevChapter != null) {
|
||||||
|
chapter.bookmark = prevChapter.bookmark
|
||||||
|
chapter.read = prevChapter.read
|
||||||
|
chapter.date_fetch = prevChapter.date_fetch
|
||||||
|
prevHistoryList.find { it.chapter_id == prevChapter.id }?.let { prevHistory ->
|
||||||
|
val history = History.create(chapter).apply { last_read = prevHistory.last_read }
|
||||||
|
historyList.add(history)
|
||||||
|
}
|
||||||
|
} else if (chapter.chapter_number <= maxChapterRead) {
|
||||||
chapter.read = true
|
chapter.read = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.insertChapters(dbChapters).executeAsBlocking()
|
|
||||||
}
|
}
|
||||||
|
db.insertChapters(dbChapters).executeAsBlocking()
|
||||||
|
db.updateHistoryLastRead(historyList).executeAsBlocking()
|
||||||
}
|
}
|
||||||
// Update categories
|
// Update categories
|
||||||
if (MigrationFlags.hasCategories(flags)) {
|
if (MigrationFlags.hasCategories(flags)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user