diff --git a/app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt b/app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt index df0f47a7e..290915001 100644 --- a/app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt +++ b/app/src/main/java/app/pachli/components/timeline/viewmodel/NetworkTimelineRemoteMediator.kt @@ -125,7 +125,7 @@ class NetworkTimelineRemoteMediator( Timeline.Home -> api.homeTimeline(maxId = maxId, minId = minId, limit = loadSize) Timeline.PublicFederated -> api.publicTimeline(local = false, maxId = maxId, minId = minId, limit = loadSize) Timeline.PublicLocal -> api.publicTimeline(local = true, maxId = maxId, minId = minId, limit = loadSize) - Timeline.TrendingStatuses -> api.trendingStatuses() + Timeline.TrendingStatuses -> api.trendingStatuses(limit = LIMIT_TRENDING_STATUSES) is Timeline.Hashtags -> { val firstHashtag = timeline.tags.first() val additionalHashtags = timeline.tags.subList(1, timeline.tags.size) @@ -167,4 +167,13 @@ class NetworkTimelineRemoteMediator( else -> throw IllegalStateException("NetworkTimelineRemoteMediator does not support $timeline") } } + + companion object { + /** + * How many trending statuses to fetch. These are not paged, so fetch the + * documented (https://docs.joinmastodon.org/methods/trends/#query-parameters-1) + * maximum. + */ + const val LIMIT_TRENDING_STATUSES = 40 + } } diff --git a/app/src/main/java/app/pachli/components/trending/TrendingLinksRepository.kt b/app/src/main/java/app/pachli/components/trending/TrendingLinksRepository.kt index 7aea9310b..ac5c795d2 100644 --- a/app/src/main/java/app/pachli/components/trending/TrendingLinksRepository.kt +++ b/app/src/main/java/app/pachli/components/trending/TrendingLinksRepository.kt @@ -23,5 +23,14 @@ import javax.inject.Inject class TrendingLinksRepository @Inject constructor( private val api: MastodonApi, ) { - suspend fun getTrendingLinks() = api.trendingLinks() + suspend fun getTrendingLinks() = api.trendingLinks(limit = LIMIT_TRENDING_LINKS) + + companion object { + /** + * How many trending links to fetch. These are not paged, so fetch the + * documented (https://docs.joinmastodon.org/methods/trends/#query-parameters-2) + * maximum. + */ + const val LIMIT_TRENDING_LINKS = 20 + } } diff --git a/app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt b/app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt index 1dd0aed18..5a8545f99 100644 --- a/app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt +++ b/app/src/main/java/app/pachli/components/trending/viewmodel/TrendingTagsViewModel.kt @@ -88,7 +88,7 @@ class TrendingTagsViewModel @Inject constructor( val deferredFilters = async { mastodonApi.getFilters() } - mastodonApi.trendingTags().fold( + mastodonApi.trendingTags(limit = LIMIT_TRENDING_HASHTAGS).fold( { tagResponse -> val firstTag = tagResponse.firstOrNull() @@ -129,4 +129,13 @@ class TrendingTagsViewModel @Inject constructor( return map { TrendingViewData.Tag.from(it, maxTrendingValue) } } + + companion object { + /** + * How many trending hashtags to fetch. These are not paged, so fetch the + * documented (https://docs.joinmastodon.org/methods/trends/#query-parameters) + * maximum. + */ + const val LIMIT_TRENDING_HASHTAGS = 20 + } } diff --git a/core/network/src/main/kotlin/app/pachli/core/network/retrofit/MastodonApi.kt b/core/network/src/main/kotlin/app/pachli/core/network/retrofit/MastodonApi.kt index f64d0eec3..42ebcad4c 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/retrofit/MastodonApi.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/retrofit/MastodonApi.kt @@ -787,11 +787,17 @@ interface MastodonApi { suspend fun unfollowTag(@Path("name") name: String): NetworkResult @GET("api/v1/trends/tags") - suspend fun trendingTags(): NetworkResult> + suspend fun trendingTags( + @Query("limit") limit: Int? = null, + ): NetworkResult> @GET("api/v1/trends/links") - suspend fun trendingLinks(): NetworkResult> + suspend fun trendingLinks( + @Query("limit") limit: Int? = null, + ): NetworkResult> @GET("api/v1/trends/statuses") - suspend fun trendingStatuses(): Response> + suspend fun trendingStatuses( + @Query("limit") limit: Int? = null, + ): Response> }