From 09b856e71c05a63b09a9869b5688b609611f4612 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Thu, 13 Apr 2023 20:28:55 +0200 Subject: [PATCH] Throttle Wikipedia requests --- .../src/main/java/de/mm20/launcher2/search/SearchService.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/search/src/main/java/de/mm20/launcher2/search/SearchService.kt b/services/search/src/main/java/de/mm20/launcher2/search/SearchService.kt index ae2ba2ef..bb31f870 100644 --- a/services/search/src/main/java/de/mm20/launcher2/search/SearchService.kt +++ b/services/search/src/main/java/de/mm20/launcher2/search/SearchService.kt @@ -39,6 +39,7 @@ import de.mm20.launcher2.wikipedia.WikipediaRepository import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.channelFlow @@ -194,6 +195,7 @@ internal class SearchServiceImpl( } if (wikipedia.enabled) { launch { + delay(750) wikipediaRepository.search(query, loadImages = wikipedia.images) .map { it?.let { listOf(it) } ?: listOf() } .withCustomLabels(customAttributesRepository)