Adapt model implementation for TachiyomiX 1.6 (#3412)
This commit is contained in:
+2
@@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.data.backup.models.backupChapterMapper
|
||||
import eu.kanade.tachiyomi.data.backup.models.backupTrackMapper
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.MemoColumnAdapter
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.history.interactor.GetHistory
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
@@ -107,4 +108,5 @@ private fun Manga.toBackupManga() =
|
||||
version = this.version,
|
||||
notes = this.notes,
|
||||
initialized = this.initialized,
|
||||
memo = MemoColumnAdapter.encode(this.memo),
|
||||
)
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package eu.kanade.tachiyomi.data.backup.models
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import mihon.core.common.extensions.EMPTY
|
||||
import tachiyomi.data.MemoColumnAdapter
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
|
||||
@Serializable
|
||||
data class BackupChapter(
|
||||
class BackupChapter(
|
||||
// in 1.x some of these values have different names
|
||||
// url is called key in 1.x
|
||||
@ProtoNumber(1) var url: String,
|
||||
@@ -22,6 +25,7 @@ data class BackupChapter(
|
||||
@ProtoNumber(10) var sourceOrder: Long = 0,
|
||||
@ProtoNumber(11) var lastModifiedAt: Long = 0,
|
||||
@ProtoNumber(12) var version: Long = 0,
|
||||
@ProtoNumber(13) var memo: ByteArray = byteArrayOf(),
|
||||
) {
|
||||
fun toChapterImpl(): Chapter {
|
||||
return Chapter.create().copy(
|
||||
@@ -37,6 +41,7 @@ data class BackupChapter(
|
||||
sourceOrder = this@BackupChapter.sourceOrder,
|
||||
lastModifiedAt = this@BackupChapter.lastModifiedAt,
|
||||
version = this@BackupChapter.version,
|
||||
memo = MemoColumnAdapter.decode(this@BackupChapter.memo),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -57,6 +62,7 @@ val backupChapterMapper = {
|
||||
lastModifiedAt: Long,
|
||||
version: Long,
|
||||
_: Long,
|
||||
memo: JsonObject,
|
||||
->
|
||||
BackupChapter(
|
||||
url = url,
|
||||
@@ -71,5 +77,6 @@ val backupChapterMapper = {
|
||||
sourceOrder = sourceOrder,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
version = version,
|
||||
memo = MemoColumnAdapter.encode(memo),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package eu.kanade.tachiyomi.data.backup.models
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import mihon.core.common.extensions.EMPTY
|
||||
import tachiyomi.data.MemoColumnAdapter
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Serializable
|
||||
data class BackupManga(
|
||||
class BackupManga(
|
||||
// in 1.x some of these values have different names
|
||||
@ProtoNumber(1) var source: Long,
|
||||
// url is called key in 1.x
|
||||
@@ -43,6 +46,7 @@ data class BackupManga(
|
||||
@ProtoNumber(109) var version: Long = 0,
|
||||
@ProtoNumber(110) var notes: String = "",
|
||||
@ProtoNumber(111) var initialized: Boolean = false,
|
||||
@ProtoNumber(112) var memo: ByteArray = byteArrayOf(),
|
||||
) {
|
||||
fun getMangaImpl(): Manga {
|
||||
return Manga.create().copy(
|
||||
@@ -65,6 +69,7 @@ data class BackupManga(
|
||||
version = this@BackupManga.version,
|
||||
notes = this@BackupManga.notes,
|
||||
initialized = this@BackupManga.initialized,
|
||||
memo = MemoColumnAdapter.decode(this@BackupManga.memo),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import eu.kanade.tachiyomi.data.backup.models.BackupHistory
|
||||
import eu.kanade.tachiyomi.data.backup.models.BackupManga
|
||||
import eu.kanade.tachiyomi.data.backup.models.BackupTracking
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.MemoColumnAdapter
|
||||
import tachiyomi.data.MemoColumnAdapter.encode
|
||||
import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
@@ -134,6 +136,7 @@ class MangaRestorer(
|
||||
version = manga.version,
|
||||
isSyncing = 1,
|
||||
notes = manga.notes,
|
||||
memo = manga.memo.let(MemoColumnAdapter::encode),
|
||||
)
|
||||
return manga
|
||||
}
|
||||
@@ -207,6 +210,7 @@ class MangaRestorer(
|
||||
chapter.dateFetch,
|
||||
chapter.dateUpload,
|
||||
chapter.version,
|
||||
chapter.memo,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -230,6 +234,7 @@ class MangaRestorer(
|
||||
chapterId = chapter.id,
|
||||
version = chapter.version,
|
||||
isSyncing = 0,
|
||||
memo = chapter.memo.let(MemoColumnAdapter::encode),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -263,6 +268,7 @@ class MangaRestorer(
|
||||
updateStrategy = manga.updateStrategy,
|
||||
version = manga.version,
|
||||
notes = manga.notes,
|
||||
memo = manga.memo,
|
||||
)
|
||||
.awaitAsOne()
|
||||
}
|
||||
|
||||
@@ -47,5 +47,6 @@ fun Chapter.toDomainChapter(): DomainChapter? {
|
||||
scanlator = scanlator,
|
||||
lastModifiedAt = last_modified,
|
||||
version = version,
|
||||
memo = memo,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
package eu.kanade.tachiyomi.data.database.models
|
||||
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
class ChapterImpl : Chapter {
|
||||
|
||||
override var id: Long? = null
|
||||
@@ -32,6 +34,8 @@ class ChapterImpl : Chapter {
|
||||
|
||||
override var version: Long = 0
|
||||
|
||||
override var memo: JsonObject = JsonObject(emptyMap())
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || javaClass != other.javaClass) return false
|
||||
|
||||
@@ -31,10 +31,12 @@ import nl.adaptivity.xmlutil.XmlDeclMode
|
||||
import nl.adaptivity.xmlutil.core.XmlVersion
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
import tachiyomi.core.common.storage.AndroidStorageFolderProvider
|
||||
import tachiyomi.data.Chapters
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.DateColumnAdapter
|
||||
import tachiyomi.data.History
|
||||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.data.MemoColumnAdapter
|
||||
import tachiyomi.data.StringListColumnAdapter
|
||||
import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
@@ -81,6 +83,10 @@ class AppModule(val app: Application) : InjektModule {
|
||||
mangasAdapter = Mangas.Adapter(
|
||||
genreAdapter = StringListColumnAdapter,
|
||||
update_strategyAdapter = UpdateStrategyColumnAdapter,
|
||||
memoAdapter = MemoColumnAdapter,
|
||||
),
|
||||
chaptersAdapter = Chapters.Adapter(
|
||||
memoAdapter = MemoColumnAdapter,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ class UpdateMangaFromRemote(
|
||||
status = remoteManga.status.toLong(),
|
||||
updateStrategy = remoteManga.update_strategy,
|
||||
initialized = true,
|
||||
memo = remoteManga.memo,
|
||||
),
|
||||
)
|
||||
if (success && title != null) {
|
||||
|
||||
Reference in New Issue
Block a user