parent
9a7e456edf
commit
f3e0ee56df
1 changed files with 18 additions and 14 deletions
|
@ -82,6 +82,11 @@ class TrendingViewModel @Inject constructor(
|
||||||
|
|
||||||
mastodonApi.trendingTags().fold(
|
mastodonApi.trendingTags().fold(
|
||||||
{ tagResponse ->
|
{ tagResponse ->
|
||||||
|
|
||||||
|
val firstTag = tagResponse.firstOrNull()
|
||||||
|
_uiState.value = if (firstTag == null) {
|
||||||
|
TrendingUiState(emptyList(), LoadingState.LOADED)
|
||||||
|
} else {
|
||||||
val homeFilters = deferredFilters.await().getOrNull()?.filter { filter ->
|
val homeFilters = deferredFilters.await().getOrNull()?.filter { filter ->
|
||||||
filter.context.contains(Filter.Kind.HOME.kind)
|
filter.context.contains(Filter.Kind.HOME.kind)
|
||||||
}
|
}
|
||||||
|
@ -94,10 +99,9 @@ class TrendingViewModel @Inject constructor(
|
||||||
.sortedByDescending { tag -> tag.history.sumOf { it.uses.toLongOrNull() ?: 0 } }
|
.sortedByDescending { tag -> tag.history.sumOf { it.uses.toLongOrNull() ?: 0 } }
|
||||||
.toViewData()
|
.toViewData()
|
||||||
|
|
||||||
val firstTag = tagResponse.first()
|
|
||||||
val header = TrendingViewData.Header(firstTag.start(), firstTag.end())
|
val header = TrendingViewData.Header(firstTag.start(), firstTag.end())
|
||||||
|
TrendingUiState(listOf(header) + tags, LoadingState.LOADED)
|
||||||
_uiState.value = TrendingUiState(listOf(header) + tags, LoadingState.LOADED)
|
}
|
||||||
},
|
},
|
||||||
{ error ->
|
{ error ->
|
||||||
Log.w(TAG, "failed loading trending tags", error)
|
Log.w(TAG, "failed loading trending tags", error)
|
||||||
|
|
Loading…
Reference in a new issue