feat: db changes to accommodate new cross device syncing logic. (#450)
* feat: db changes to accommodate new syncing logic. Using timestamp to sync is a bit skewed due to system clock etc and therefore there was a lot of issues with it such as removing a manga that shouldn't have been removed. Marking chapters as unread even though it was marked as a read. Hopefully by using versioning system it should eliminate those issues. * chore: add new line. * chore: remove isSyncing from Chapter/Manga model. * chore: remove isSyncing leftover. * chore: remove isSyncing. * refactor: remove isSync guard. Just use it directly to 1 now since we don't have the isSyncing field in Manga or Chapter. * Lint and stuff * Add missing , --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 4ae9dbe52487185ef9ee25f58fabe5025bb2278b) # Conflicts: # app/build.gradle.kts # app/src/main/java/eu/kanade/tachiyomi/data/backup/create/creators/MangaBackupCreator.kt # app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt # app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt # data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt # data/src/main/sqldelight/tachiyomi/migrations/2.sqm # domain/src/main/java/tachiyomi/domain/manga/model/MangaUpdate.kt
This commit is contained in:
@@ -32,13 +32,15 @@ private val mapper = { cursor: SqlCursor ->
|
||||
calculate_interval = cursor.getLong(20)!!,
|
||||
last_modified_at = cursor.getLong(21)!!,
|
||||
favorite_modified_at = cursor.getLong(22),
|
||||
totalCount = cursor.getLong(23)!!,
|
||||
readCount = cursor.getDouble(24)!!,
|
||||
latestUpload = cursor.getLong(25)!!,
|
||||
chapterFetchedAt = cursor.getLong(26)!!,
|
||||
lastRead = cursor.getLong(27)!!,
|
||||
bookmarkCount = cursor.getDouble(28)!!,
|
||||
category = cursor.getLong(29)!!,
|
||||
version = cursor.getLong(23)!!,
|
||||
is_syncing = cursor.getLong(24)!!,
|
||||
totalCount = cursor.getLong(25)!!,
|
||||
readCount = cursor.getDouble(26)!!,
|
||||
latestUpload = cursor.getLong(27)!!,
|
||||
chapterFetchedAt = cursor.getLong(28)!!,
|
||||
lastRead = cursor.getLong(29)!!,
|
||||
bookmarkCount = cursor.getDouble(30)!!,
|
||||
category = cursor.getLong(31)!!,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ object ChapterMapper {
|
||||
dateFetch: Long,
|
||||
dateUpload: Long,
|
||||
lastModifiedAt: Long,
|
||||
version: Long,
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
isSyncing: Long,
|
||||
): Chapter = Chapter(
|
||||
id = id,
|
||||
mangaId = mangaId,
|
||||
@@ -31,5 +34,6 @@ object ChapterMapper {
|
||||
chapterNumber = chapterNumber,
|
||||
scanlator = scanlator,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
version = version
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class ChapterRepositoryImpl(
|
||||
chapter.sourceOrder,
|
||||
chapter.dateFetch,
|
||||
chapter.dateUpload,
|
||||
chapter.version,
|
||||
)
|
||||
val lastInsertId = chaptersQueries.selectLastInsertedRowId().executeAsOne()
|
||||
chapter.copy(id = lastInsertId)
|
||||
@@ -64,6 +65,8 @@ class ChapterRepositoryImpl(
|
||||
dateFetch = chapterUpdate.dateFetch,
|
||||
dateUpload = chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
version = chapterUpdate.version,
|
||||
isSyncing = 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.view.LibraryView
|
||||
|
||||
object MangaMapper {
|
||||
@Suppress("LongParameterList")
|
||||
fun mapManga(
|
||||
id: Long,
|
||||
source: Long,
|
||||
@@ -33,6 +34,9 @@ object MangaMapper {
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
isSyncing: Long,
|
||||
): Manga = Manga(
|
||||
id = id,
|
||||
source = source,
|
||||
@@ -58,8 +62,10 @@ object MangaMapper {
|
||||
initialized = initialized,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
favoriteModifiedAt = favoriteModifiedAt,
|
||||
version = version,
|
||||
)
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
fun mapLibraryManga(
|
||||
id: Long,
|
||||
source: Long,
|
||||
@@ -87,6 +93,8 @@ object MangaMapper {
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
totalCount: Long,
|
||||
readCount: Double,
|
||||
latestUpload: Long,
|
||||
@@ -121,6 +129,8 @@ object MangaMapper {
|
||||
calculateInterval,
|
||||
lastModifiedAt,
|
||||
favoriteModifiedAt,
|
||||
version,
|
||||
isSyncing,
|
||||
),
|
||||
category = category,
|
||||
totalChapters = totalCount,
|
||||
@@ -156,6 +166,7 @@ object MangaMapper {
|
||||
fetchInterval = libraryView.calculate_interval.toInt(),
|
||||
lastModifiedAt = libraryView.last_modified_at,
|
||||
favoriteModifiedAt = libraryView.favorite_modified_at,
|
||||
version = libraryView.version,
|
||||
),
|
||||
category = libraryView.category,
|
||||
totalChapters = libraryView.totalCount,
|
||||
|
||||
@@ -119,6 +119,7 @@ class MangaRepositoryImpl(
|
||||
coverLastModified = manga.coverLastModified,
|
||||
dateAdded = manga.dateAdded,
|
||||
updateStrategy = manga.updateStrategy,
|
||||
version = manga.version,
|
||||
)
|
||||
mangasQueries.selectLastInsertedRowId()
|
||||
}
|
||||
@@ -168,6 +169,8 @@ class MangaRepositoryImpl(
|
||||
dateAdded = value.dateAdded,
|
||||
mangaId = value.id,
|
||||
updateStrategy = value.updateStrategy?.let(UpdateStrategyColumnAdapter::encode),
|
||||
version = value.version,
|
||||
isSyncing = 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user