mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 12:11:50 +01:00
Fix checking downloads banner showing up incorrectly
This commit is contained in:
parent
58ebf14691
commit
5b5eb92184
@ -21,17 +21,15 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.flow.shareIn
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.take
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import logcat.LogPriority
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -72,10 +70,9 @@ class DownloadCache(
|
||||
*/
|
||||
private var lastRenew = 0L
|
||||
private var renewalJob: Job? = null
|
||||
val isRenewing = changes
|
||||
.map { renewalJob?.isActive ?: false }
|
||||
.distinctUntilChanged()
|
||||
.take(2) // We only care about initial renewal
|
||||
|
||||
private val _isInitializing = MutableStateFlow(false)
|
||||
val isInitializing = _isInitializing
|
||||
.debounce(1000L) // Don't notify if it finishes quickly enough
|
||||
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
|
||||
|
||||
@ -272,6 +269,10 @@ class DownloadCache(
|
||||
}
|
||||
|
||||
renewalJob = scope.launchIO {
|
||||
if (lastRenew == 0L) {
|
||||
_isInitializing.emit(true)
|
||||
}
|
||||
|
||||
var sources = getSources()
|
||||
|
||||
// Try to wait until extensions and sources have loaded
|
||||
@ -326,6 +327,8 @@ class DownloadCache(
|
||||
}
|
||||
}
|
||||
.awaitAll()
|
||||
|
||||
_isInitializing.emit(false)
|
||||
}.also {
|
||||
it.invokeOnCompletion(onCancelling = true) { exception ->
|
||||
if (exception != null && exception !is CancellationException) {
|
||||
|
@ -162,7 +162,7 @@ class MainActivity : BaseActivity() {
|
||||
setComposeContent {
|
||||
val incognito by preferences.incognitoMode().collectAsState()
|
||||
val downloadOnly by preferences.downloadedOnly().collectAsState()
|
||||
val indexing by downloadCache.isRenewing.collectAsState()
|
||||
val indexing by downloadCache.isInitializing.collectAsState()
|
||||
|
||||
// Set statusbar color considering the top app state banner
|
||||
val systemUiController = rememberSystemUiController()
|
||||
|
Loading…
Reference in New Issue
Block a user