Reset new chapters on reading

This commit is contained in:
Koitharu
2020-04-25 17:17:50 +03:00
parent 0d0982b244
commit f95cf9b231
4 changed files with 16 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ import java.util.*
class HistoryRepository : KoinComponent {
private val db: MangaDatabase by inject()
private val trackingRepository by lazy(::TrackingRepository)
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
val entities = db.historyDao.findAll(offset, limit)
@@ -28,19 +29,17 @@ class HistoryRepository : KoinComponent {
db.withTransaction {
db.tagsDao.upsert(tags)
db.mangaDao.upsert(MangaEntity.from(manga), tags)
if (db.historyDao.upsert(
HistoryEntity(
mangaId = manga.id,
createdAt = System.currentTimeMillis(),
updatedAt = System.currentTimeMillis(),
chapterId = chapterId,
page = page,
scroll = scroll
)
db.historyDao.upsert(
HistoryEntity(
mangaId = manga.id,
createdAt = System.currentTimeMillis(),
updatedAt = System.currentTimeMillis(),
chapterId = chapterId,
page = page,
scroll = scroll
)
) {
TrackingRepository().insertOrNothing(manga)
}
)
trackingRepository.upsert(manga)
}
notifyHistoryChanged()
}

View File

@@ -52,7 +52,7 @@ class TrackingRepository : KoinComponent {
db.tracksDao.upsert(entity)
}
suspend fun insertOrNothing(manga: Manga) {
suspend fun upsert(manga: Manga) {
val chapters = manga.chapters ?: return
val entity = TrackEntity(
mangaId = manga.id,
@@ -62,6 +62,6 @@ class TrackingRepository : KoinComponent {
lastCheck = System.currentTimeMillis(),
lastNotifiedChapterId = 0L
)
db.tracksDao.insert(entity)
db.tracksDao.upsert(entity)
}
}

View File

@@ -9,7 +9,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
classpath 'com.android.tools.build:gradle:4.1.0-alpha07'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -1,6 +1,6 @@
#Sat Apr 18 10:00:24 EEST 2020
#Sat Apr 25 17:13:08 EEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-2-all.zip