mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 18:39:19 +01:00
Perform mark as read action in IO coroutine scope to avoid freezing app
This commit is contained in:
parent
10272ef395
commit
79bc1290ae
@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.source.SourceManager
|
|||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
@ -170,17 +171,23 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
val preferences: PreferencesHelper = Injekt.get()
|
val preferences: PreferencesHelper = Injekt.get()
|
||||||
val sourceManager: SourceManager = Injekt.get()
|
val sourceManager: SourceManager = Injekt.get()
|
||||||
|
|
||||||
|
launchIO {
|
||||||
chapterUrls.mapNotNull { db.getChapter(it, mangaId).executeAsBlocking() }
|
chapterUrls.mapNotNull { db.getChapter(it, mangaId).executeAsBlocking() }
|
||||||
.forEach {
|
.forEach {
|
||||||
it.read = true
|
it.read = true
|
||||||
db.updateChapterProgress(it).executeAsBlocking()
|
db.updateChapterProgress(it).executeAsBlocking()
|
||||||
if (preferences.removeAfterMarkedAsRead()) {
|
if (preferences.removeAfterMarkedAsRead()) {
|
||||||
val manga = db.getManga(mangaId).executeAsBlocking() ?: return
|
val manga = db.getManga(mangaId).executeAsBlocking()
|
||||||
val source = sourceManager.get(manga.source) ?: return
|
if (manga != null) {
|
||||||
|
val source = sourceManager.get(manga.source)
|
||||||
|
if (source != null) {
|
||||||
downloadManager.deleteChapters(listOf(it), manga, source)
|
downloadManager.deleteChapters(listOf(it), manga, source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val NAME = "NotificationReceiver"
|
private const val NAME = "NotificationReceiver"
|
||||||
|
Loading…
Reference in New Issue
Block a user