Only how indexing downloads banner the first time

Closes #8903
This commit is contained in:
arkon
2023-01-13 18:40:59 -05:00
parent 1967923a94
commit b6468c7e31
3 changed files with 6 additions and 6 deletions

View File

@ -31,12 +31,13 @@ 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
import uy.kohesive.injekt.api.get
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.TimeUnit
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.seconds
/**
@ -64,7 +65,7 @@ class DownloadCache(
* The interval after which this cache should be invalidated. 1 hour shouldn't cause major
* issues, as the cache is only used for UI feedback.
*/
private val renewInterval = TimeUnit.HOURS.toMillis(1)
private val renewInterval = 1.hours.inWholeMilliseconds
/**
* The last time the cache was refreshed.
@ -74,7 +75,8 @@ class DownloadCache(
val isRenewing = changes
.map { renewalJob?.isActive ?: false }
.distinctUntilChanged()
.debounce(1000L)
.take(2) // We only care about initial renewal
.debounce(1000L) // Don't notify if it finishes quickly enough
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
private var rootDownloadsDir = RootDirectory(getDirectoryFromPreference())

View File

@ -140,7 +140,6 @@ abstract class SearchScreenModel<T>(
async {
try {
val page = withContext(coroutineDispatcher) {
logcat { "Searching ${source.name}" }
source.fetchSearchManga(1, query, source.getFilterList()).awaitSingle()
}