mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -14,6 +14,7 @@ data class Chapter(
 | 
			
		||||
    val chapterNumber: Double,
 | 
			
		||||
    val scanlator: String?,
 | 
			
		||||
    val lastModifiedAt: Long,
 | 
			
		||||
    val version: Long,
 | 
			
		||||
) {
 | 
			
		||||
    val isRecognizedNumber: Boolean
 | 
			
		||||
        get() = chapterNumber >= 0f
 | 
			
		||||
@@ -43,6 +44,7 @@ data class Chapter(
 | 
			
		||||
            chapterNumber = -1.0,
 | 
			
		||||
            scanlator = null,
 | 
			
		||||
            lastModifiedAt = 0,
 | 
			
		||||
            version = 1,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ data class ChapterUpdate(
 | 
			
		||||
    val dateUpload: Long? = null,
 | 
			
		||||
    val chapterNumber: Double? = null,
 | 
			
		||||
    val scanlator: String? = null,
 | 
			
		||||
    val version: Long? = null,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
fun Chapter.toChapterUpdate(): ChapterUpdate {
 | 
			
		||||
@@ -29,5 +30,6 @@ fun Chapter.toChapterUpdate(): ChapterUpdate {
 | 
			
		||||
        dateUpload,
 | 
			
		||||
        chapterNumber,
 | 
			
		||||
        scanlator,
 | 
			
		||||
        version,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@ data class Manga(
 | 
			
		||||
    val initialized: Boolean,
 | 
			
		||||
    val lastModifiedAt: Long,
 | 
			
		||||
    val favoriteModifiedAt: Long?,
 | 
			
		||||
    val version: Long,
 | 
			
		||||
) : Serializable {
 | 
			
		||||
 | 
			
		||||
    val expectedNextUpdate: Instant?
 | 
			
		||||
@@ -122,6 +123,7 @@ data class Manga(
 | 
			
		||||
            initialized = false,
 | 
			
		||||
            lastModifiedAt = 0L,
 | 
			
		||||
            favoriteModifiedAt = null,
 | 
			
		||||
            version = 0L,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ data class MangaUpdate(
 | 
			
		||||
    val thumbnailUrl: String? = null,
 | 
			
		||||
    val updateStrategy: UpdateStrategy? = null,
 | 
			
		||||
    val initialized: Boolean? = null,
 | 
			
		||||
    val version: Long? = null,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
fun Manga.toMangaUpdate(): MangaUpdate {
 | 
			
		||||
@@ -47,5 +48,6 @@ fun Manga.toMangaUpdate(): MangaUpdate {
 | 
			
		||||
        thumbnailUrl = thumbnailUrl,
 | 
			
		||||
        updateStrategy = updateStrategy,
 | 
			
		||||
        initialized = initialized,
 | 
			
		||||
        version = version,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user