Improve/Fix E-H redirect, add history handling, fix redirect and library handling
This commit is contained in:
@@ -5,6 +5,7 @@ import com.pushtorefresh.storio.sqlite.queries.RawQuery
|
||||
import eu.kanade.tachiyomi.data.database.DbProvider
|
||||
import eu.kanade.tachiyomi.data.database.models.History
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
||||
import eu.kanade.tachiyomi.data.database.resolvers.HistoryChapterIdPutResolver
|
||||
import eu.kanade.tachiyomi.data.database.resolvers.HistoryLastReadPutResolver
|
||||
import eu.kanade.tachiyomi.data.database.resolvers.MangaChapterHistoryGetResolver
|
||||
import eu.kanade.tachiyomi.data.database.tables.HistoryTable
|
||||
@@ -96,4 +97,11 @@ interface HistoryQueries : DbProvider {
|
||||
.build()
|
||||
)
|
||||
.prepare()
|
||||
|
||||
// SY -->
|
||||
fun updateHistoryChapterIds(history: List<History>) = db.put()
|
||||
.objects(history)
|
||||
.withPutResolver(HistoryChapterIdPutResolver())
|
||||
.prepare()
|
||||
// SY <--
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package eu.kanade.tachiyomi.data.database.resolvers
|
||||
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.pushtorefresh.storio.sqlite.StorIOSQLite
|
||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResolver
|
||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResult
|
||||
import com.pushtorefresh.storio.sqlite.queries.UpdateQuery
|
||||
import eu.kanade.tachiyomi.data.database.inTransactionReturn
|
||||
import eu.kanade.tachiyomi.data.database.models.History
|
||||
import eu.kanade.tachiyomi.data.database.tables.HistoryTable
|
||||
|
||||
class HistoryChapterIdPutResolver : PutResolver<History>() {
|
||||
|
||||
override fun performPut(db: StorIOSQLite, history: History) = db.inTransactionReturn {
|
||||
val updateQuery = mapToUpdateQuery(history)
|
||||
val contentValues = mapToContentValues(history)
|
||||
|
||||
val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
|
||||
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
|
||||
}
|
||||
|
||||
fun mapToUpdateQuery(history: History) = UpdateQuery.builder()
|
||||
.table(HistoryTable.TABLE)
|
||||
.where("${HistoryTable.COL_ID} = ?")
|
||||
.whereArgs(history.id)
|
||||
.build()
|
||||
|
||||
fun mapToContentValues(history: History) =
|
||||
contentValuesOf(
|
||||
HistoryTable.COL_CHAPTER_ID to history.chapter_id
|
||||
)
|
||||
}
|
||||
@@ -255,7 +255,7 @@ class MangaPresenter(
|
||||
val ourChapterUrls = chapters.map { it.url }.toSet()
|
||||
val acceptedChapterUrls = acceptedChain.chapters.map { it.url }.toSet()
|
||||
val update = (ourChapterUrls - acceptedChapterUrls).isNotEmpty()
|
||||
redirectFlow.tryEmit(
|
||||
redirectFlow.emit(
|
||||
EXHRedirect(
|
||||
acceptedChain.manga,
|
||||
update
|
||||
|
||||
Reference in New Issue
Block a user