Browse Source

Only update chapter/viewer flags for library manga instead of everything (addresses #5809)

arkon 3 năm trước cách đây
mục cha
commit
7fa80ae556

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt

@@ -81,7 +81,7 @@ interface MangaQueries : DbProvider {
 
     fun updateChapterFlags(manga: List<Manga>) = db.put()
         .objects(manga)
-        .withPutResolver(MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags, true))
+        .withPutResolver(MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags))
         .prepare()
 
     fun updateViewerFlags(manga: Manga) = db.put()
@@ -91,7 +91,7 @@ interface MangaQueries : DbProvider {
 
     fun updateViewerFlags(manga: List<Manga>) = db.put()
         .objects(manga)
-        .withPutResolver(MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags, true))
+        .withPutResolver(MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags))
         .prepare()
 
     fun updateNextUpdated(manga: Manga) = db.put()

+ 2 - 14
app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt

@@ -27,9 +27,7 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
                 .build()
         )
 
-        val putResult: PutResult
-
-        putResult = cursor.use { putCursor ->
+        cursor.use { putCursor ->
             if (putCursor.count == 0) {
                 val insertQuery = mapToInsertQuery(history)
                 val insertedId = db.lowLevel().insert(insertQuery, mapToContentValues(history))
@@ -39,25 +37,15 @@ class HistoryLastReadPutResolver : HistoryPutResolver() {
                 PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
             }
         }
-
-        putResult
     }
 
-    /**
-     * Creates update query
-     * @param obj history object
-     */
     override fun mapToUpdateQuery(obj: History) = UpdateQuery.builder()
         .table(HistoryTable.TABLE)
         .where("${HistoryTable.COL_CHAPTER_ID} = ?")
         .whereArgs(obj.chapter_id)
         .build()
 
-    /**
-     * Create content query
-     * @param history object
-     */
-    fun mapToUpdateContentValues(history: History) =
+    private fun mapToUpdateContentValues(history: History) =
         contentValuesOf(
             HistoryTable.COL_LAST_READ to history.last_read
         )

+ 6 - 16
app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt

@@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
 import eu.kanade.tachiyomi.data.database.tables.MangaTable
 import kotlin.reflect.KProperty1
 
-class MangaFlagsPutResolver(private val colName: String, private val fieldGetter: KProperty1<Manga, Int>, private val updateAll: Boolean = false) : PutResolver<Manga>() {
+class MangaFlagsPutResolver(private val colName: String, private val fieldGetter: KProperty1<Manga, Int>) : PutResolver<Manga>() {
 
     override fun performPut(db: StorIOSQLite, manga: Manga) = db.inTransactionReturn {
         val updateQuery = mapToUpdateQuery(manga)
@@ -20,21 +20,11 @@ class MangaFlagsPutResolver(private val colName: String, private val fieldGetter
         PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
     }
 
-    fun mapToUpdateQuery(manga: Manga): UpdateQuery {
-        val builder = UpdateQuery.builder()
-
-        return if (updateAll) {
-            builder
-                .table(MangaTable.TABLE)
-                .build()
-        } else {
-            builder
-                .table(MangaTable.TABLE)
-                .where("${MangaTable.COL_ID} = ?")
-                .whereArgs(manga.id)
-                .build()
-        }
-    }
+    fun mapToUpdateQuery(manga: Manga) = UpdateQuery.builder()
+        .table(MangaTable.TABLE)
+        .where("${MangaTable.COL_ID} = ?")
+        .whereArgs(manga.id)
+        .build()
 
     fun mapToContentValues(manga: Manga) =
         contentValuesOf(