Minor cleanup in ImageUtil and SourceFilterPresenter (#7106)

* Minor cleanup in `ImageUtil` and `SourceFilterPresenter`

* Fix missed stuff
This commit is contained in:
FourTOne5
2022-05-14 21:34:15 +06:00
committed by GitHub
parent 6d011ebe32
commit 71bb8ed975
4 changed files with 29 additions and 18 deletions

View File

@@ -33,15 +33,12 @@ class SourceFilterPresenter(
.catch { exception ->
_state.value = SourceFilterState.Error(exception)
}
.collectLatest { sourceLangMap ->
val uiModels = sourceLangMap.toFilterUiModels()
_state.value = SourceFilterState.Success(uiModels)
}
.collectLatest(::collectLatestSourceLangMap)
}
}
private fun Map<String, List<Source>>.toFilterUiModels(): List<FilterUiModel> {
return this.flatMap {
private fun collectLatestSourceLangMap(sourceLangMap: Map<String, List<Source>>) {
val uiModels = sourceLangMap.flatMap {
val isLangEnabled = it.key in preferences.enabledLanguages().get()
val header = listOf(FilterUiModel.Header(it.key, isLangEnabled))
@@ -53,6 +50,7 @@ class SourceFilterPresenter(
)
}
}
_state.value = SourceFilterState.Success(uiModels)
}
fun toggleSource(source: Source) {