File tree Expand file tree Collapse file tree 2 files changed +3
-9
lines changed
app/src/main/java/org/wikipedia Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ class RandomClient(
3030 cb.error(caught)
3131 }
3232 ) {
33- val list = mutableListOf<RandomCard >()
3433 val deferredSummaries = WikipediaApp .instance.languageState.appLanguageCodes
3534 .filter { ! FeedContentType .RANDOM .langCodesDisabled.contains(it) }
3635 .map { lang ->
@@ -49,9 +48,7 @@ class RandomClient(
4948 }
5049 }
5150
52- val randomCards = deferredSummaries.awaitAll().filterNotNull()
53- list.addAll(randomCards)
54- cb.success(list)
51+ cb.success(deferredSummaries.awaitAll().filterNotNull())
5552 }
5653 }
5754
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import android.util.SparseArray
77import android.view.View
88import androidx.annotation.StringRes
99import androidx.core.os.ConfigurationCompat
10- import kotlinx.coroutines.Deferred
1110import kotlinx.coroutines.Dispatchers
1211import kotlinx.coroutines.async
1312import kotlinx.coroutines.awaitAll
@@ -154,14 +153,12 @@ object L10nUtil {
154153 }
155154
156155 // Third, update the extracts from the page/summary endpoint if needed.
157- val summaryForExtractsDeferred = mutableListOf<Deferred <PageSummary >>()
158156 if (shouldUpdateExtracts) {
159- summaryForExtractsDeferred.addAll( list.map { pageSummary ->
157+ list.map { pageSummary ->
160158 async {
161159 ServiceFactory .getRest(wikiSite).getPageSummary(null , pageSummary.apiTitle)
162160 }
163- })
164- summaryForExtractsDeferred.awaitAll().forEachIndexed { index, pageSummary ->
161+ }.awaitAll().forEachIndexed { index, pageSummary ->
165162 list[index].extract = pageSummary.extract
166163 list[index].extractHtml = pageSummary.extractHtml
167164 }
You can’t perform that action at this time.
0 commit comments