|
@@ -11,6 +11,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
|
|
|
+import eu.kanade.tachiyomi.data.track.job.DelayedTrackingStore
|
|
|
|
+import eu.kanade.tachiyomi.data.track.job.DelayedTrackingUpdateJob
|
|
import eu.kanade.tachiyomi.source.LocalSource
|
|
import eu.kanade.tachiyomi.source.LocalSource
|
|
import eu.kanade.tachiyomi.source.SourceManager
|
|
import eu.kanade.tachiyomi.source.SourceManager
|
|
import eu.kanade.tachiyomi.source.model.Page
|
|
import eu.kanade.tachiyomi.source.model.Page
|
|
@@ -31,6 +33,7 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|
import eu.kanade.tachiyomi.util.storage.getPicturesDir
|
|
import eu.kanade.tachiyomi.util.storage.getPicturesDir
|
|
import eu.kanade.tachiyomi.util.storage.getTempShareDir
|
|
import eu.kanade.tachiyomi.util.storage.getTempShareDir
|
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
|
|
|
+import eu.kanade.tachiyomi.util.system.isOnline
|
|
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
|
import eu.kanade.tachiyomi.util.updateCoverLastModified
|
|
import kotlinx.coroutines.async
|
|
import kotlinx.coroutines.async
|
|
import kotlinx.coroutines.awaitAll
|
|
import kotlinx.coroutines.awaitAll
|
|
@@ -53,7 +56,8 @@ class ReaderPresenter(
|
|
private val sourceManager: SourceManager = Injekt.get(),
|
|
private val sourceManager: SourceManager = Injekt.get(),
|
|
private val downloadManager: DownloadManager = Injekt.get(),
|
|
private val downloadManager: DownloadManager = Injekt.get(),
|
|
private val coverCache: CoverCache = Injekt.get(),
|
|
private val coverCache: CoverCache = Injekt.get(),
|
|
- private val preferences: PreferencesHelper = Injekt.get()
|
|
|
|
|
|
+ private val preferences: PreferencesHelper = Injekt.get(),
|
|
|
|
+ private val delayedTrackingStore: DelayedTrackingStore = Injekt.get(),
|
|
) : BasePresenter<ReaderActivity>() {
|
|
) : BasePresenter<ReaderActivity>() {
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -701,6 +705,7 @@ class ReaderPresenter(
|
|
val chapterRead = readerChapter.chapter.chapter_number
|
|
val chapterRead = readerChapter.chapter.chapter_number
|
|
|
|
|
|
val trackManager = Injekt.get<TrackManager>()
|
|
val trackManager = Injekt.get<TrackManager>()
|
|
|
|
+ val context = Injekt.get<Application>()
|
|
|
|
|
|
launchIO {
|
|
launchIO {
|
|
db.getTracks(manga).executeAsBlocking()
|
|
db.getTracks(manga).executeAsBlocking()
|
|
@@ -713,8 +718,13 @@ class ReaderPresenter(
|
|
// for a while. The view can still be garbage collected.
|
|
// for a while. The view can still be garbage collected.
|
|
async {
|
|
async {
|
|
runCatching {
|
|
runCatching {
|
|
- service.update(track, true)
|
|
|
|
- db.insertTrack(track).executeAsBlocking()
|
|
|
|
|
|
+ if (context.isOnline()) {
|
|
|
|
+ service.update(track, true)
|
|
|
|
+ db.insertTrack(track).executeAsBlocking()
|
|
|
|
+ } else {
|
|
|
|
+ delayedTrackingStore.addItem(track)
|
|
|
|
+ DelayedTrackingUpdateJob.setupTask(context)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|