mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-20 07:32:28 -07:00
Build manga and chapter updates with a lambda and track assigned fields
MangaUpdate and ChapterUpdate are built with a lambda that records which fields were assigned, so an update writes only those fields.
This commit is contained in:
@@ -82,7 +82,6 @@ class ChapterRepositoryImpl(
|
||||
database.transaction {
|
||||
chapterUpdates.forEach { chapterUpdate ->
|
||||
database.chaptersQueries.update(
|
||||
mangaId = chapterUpdate.mangaId,
|
||||
read = chapterUpdate.read,
|
||||
bookmark = chapterUpdate.bookmark,
|
||||
lastPageRead = chapterUpdate.lastPageRead,
|
||||
|
||||
@@ -245,18 +245,20 @@ class MangaRepositoryImpl(
|
||||
private suspend fun partialUpdate(vararg mangaUpdates: MangaUpdate) {
|
||||
database.transaction {
|
||||
mangaUpdates.forEach { value ->
|
||||
database.mangasQueries.update(
|
||||
favorite = value.favorite,
|
||||
lastUpdate = value.lastUpdate,
|
||||
nextUpdate = value.nextUpdate,
|
||||
calculateInterval = value.fetchInterval?.toLong(),
|
||||
viewer = value.viewerFlags,
|
||||
chapterFlags = value.chapterFlags,
|
||||
coverLastModified = value.coverLastModified,
|
||||
dateAdded = value.dateAdded,
|
||||
mangaId = value.id,
|
||||
notes = value.notes,
|
||||
)
|
||||
with(value) {
|
||||
database.mangasQueries.update(
|
||||
favorite = favorite,
|
||||
lastUpdate = lastUpdate,
|
||||
nextUpdate = nextUpdate,
|
||||
calculateInterval = fetchInterval?.toLong(),
|
||||
viewer = viewerFlags,
|
||||
chapterFlags = chapterFlags,
|
||||
coverLastModified = coverLastModified,
|
||||
dateAdded = dateAdded,
|
||||
mangaId = id,
|
||||
notes = notes,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user