Reset new chapters on reading
This commit is contained in:
@@ -17,6 +17,7 @@ import java.util.*
|
|||||||
class HistoryRepository : KoinComponent {
|
class HistoryRepository : KoinComponent {
|
||||||
|
|
||||||
private val db: MangaDatabase by inject()
|
private val db: MangaDatabase by inject()
|
||||||
|
private val trackingRepository by lazy(::TrackingRepository)
|
||||||
|
|
||||||
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
|
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
|
||||||
val entities = db.historyDao.findAll(offset, limit)
|
val entities = db.historyDao.findAll(offset, limit)
|
||||||
@@ -28,19 +29,17 @@ class HistoryRepository : KoinComponent {
|
|||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
db.tagsDao.upsert(tags)
|
db.tagsDao.upsert(tags)
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
||||||
if (db.historyDao.upsert(
|
db.historyDao.upsert(
|
||||||
HistoryEntity(
|
HistoryEntity(
|
||||||
mangaId = manga.id,
|
mangaId = manga.id,
|
||||||
createdAt = System.currentTimeMillis(),
|
createdAt = System.currentTimeMillis(),
|
||||||
updatedAt = System.currentTimeMillis(),
|
updatedAt = System.currentTimeMillis(),
|
||||||
chapterId = chapterId,
|
chapterId = chapterId,
|
||||||
page = page,
|
page = page,
|
||||||
scroll = scroll
|
scroll = scroll
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) {
|
)
|
||||||
TrackingRepository().insertOrNothing(manga)
|
trackingRepository.upsert(manga)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
notifyHistoryChanged()
|
notifyHistoryChanged()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class TrackingRepository : KoinComponent {
|
|||||||
db.tracksDao.upsert(entity)
|
db.tracksDao.upsert(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun insertOrNothing(manga: Manga) {
|
suspend fun upsert(manga: Manga) {
|
||||||
val chapters = manga.chapters ?: return
|
val chapters = manga.chapters ?: return
|
||||||
val entity = TrackEntity(
|
val entity = TrackEntity(
|
||||||
mangaId = manga.id,
|
mangaId = manga.id,
|
||||||
@@ -62,6 +62,6 @@ class TrackingRepository : KoinComponent {
|
|||||||
lastCheck = System.currentTimeMillis(),
|
lastCheck = System.currentTimeMillis(),
|
||||||
lastNotifiedChapterId = 0L
|
lastNotifiedChapterId = 0L
|
||||||
)
|
)
|
||||||
db.tracksDao.insert(entity)
|
db.tracksDao.upsert(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
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"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sat Apr 18 10:00:24 EEST 2020
|
#Sat Apr 25 17:13:08 EEST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user