Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class RandomClient(
cb.error(caught)
}
) {
val list = mutableListOf<RandomCard>()
val deferredSummaries = WikipediaApp.instance.languageState.appLanguageCodes
.filter { !FeedContentType.RANDOM.langCodesDisabled.contains(it) }
.map { lang ->
Expand All @@ -49,9 +48,7 @@ class RandomClient(
}
}

val randomCards = deferredSummaries.awaitAll().filterNotNull()
list.addAll(randomCards)
cb.success(list)
cb.success(deferredSummaries.awaitAll().filterNotNull())
}
}

Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/org/wikipedia/util/L10nUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.util.SparseArray
import android.view.View
import androidx.annotation.StringRes
import androidx.core.os.ConfigurationCompat
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
Expand Down Expand Up @@ -154,14 +153,12 @@ object L10nUtil {
}

// Third, update the extracts from the page/summary endpoint if needed.
val summaryForExtractsDeferred = mutableListOf<Deferred<PageSummary>>()
if (shouldUpdateExtracts) {
summaryForExtractsDeferred.addAll(list.map { pageSummary ->
list.map { pageSummary ->
async {
ServiceFactory.getRest(wikiSite).getPageSummary(null, pageSummary.apiTitle)
}
})
summaryForExtractsDeferred.awaitAll().forEachIndexed { index, pageSummary ->
}.awaitAll().forEachIndexed { index, pageSummary ->
list[index].extract = pageSummary.extract
list[index].extractHtml = pageSummary.extractHtml
}
Expand Down