Fix empty tracker log records

This commit is contained in:
Koitharu
2020-06-05 19:25:10 +03:00
parent 680fc66f21
commit 10a0f0ad53

View File

@@ -61,12 +61,11 @@ class TrackingRepository : KoinComponent {
lastNotifiedChapterId = newChapters.lastOrNull()?.id ?: previousTrackChapterId
)
db.tracksDao.upsert(entity)
if (newChapters.isNotEmpty()) {
val foundChapters = newChapters.takeLastWhile { x -> x.id != previousTrackChapterId }
if (foundChapters.isNotEmpty()) {
val logEntity = TrackLogEntity(
mangaId = mangaId,
chapters = newChapters
.takeLastWhile { x -> x.id != previousTrackChapterId }
.joinToString("\n") { x -> x.name },
chapters = foundChapters.joinToString("\n") { x -> x.name },
createdAt = System.currentTimeMillis()
)
db.trackLogsDao.insert(logEntity)