feat: 实现探索动态功能
在动态列表中新增探索动态功能,允许用户浏览和发现新的动态内容。 具体修改包括: - 在API接口中添加`explore`参数,用于请求探索动态数据。 - 修改MomentService,添加`explore`参数,用于获取探索动态数据。 - 更新MomentViewModel,使用`explore`参数请求探索动态数据。 - 修改MomentPagingSource,使用`explore`参数请求探索动态数据。 - 修改MomentCard,使用`explore`参数显示探索动态数据。
This commit is contained in:
@@ -27,6 +27,7 @@ class MomentPagingSource(
|
||||
private val timelineId: Int? = null,
|
||||
private val contentSearch: String? = null,
|
||||
private val trend: Boolean? = false,
|
||||
private val explore: Boolean? = false,
|
||||
private val favoriteUserId: Int? = null
|
||||
) : PagingSource<Int, MomentEntity>() {
|
||||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MomentEntity> {
|
||||
@@ -38,6 +39,7 @@ class MomentPagingSource(
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch,
|
||||
trend = trend,
|
||||
explore = explore,
|
||||
favoriteUserId = favoriteUserId
|
||||
)
|
||||
|
||||
@@ -66,6 +68,7 @@ class MomentRemoteDataSource(
|
||||
timelineId: Int?,
|
||||
contentSearch: String?,
|
||||
trend: Boolean?,
|
||||
explore: Boolean?,
|
||||
favoriteUserId: Int?
|
||||
): ListContainer<MomentEntity> {
|
||||
return momentService.getMoments(
|
||||
@@ -74,6 +77,7 @@ class MomentRemoteDataSource(
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch,
|
||||
trend = trend,
|
||||
explore = explore,
|
||||
favoriteUserId = favoriteUserId
|
||||
)
|
||||
}
|
||||
@@ -88,7 +92,8 @@ class MomentServiceImpl() : MomentService {
|
||||
timelineId: Int?,
|
||||
contentSearch: String?,
|
||||
trend: Boolean?,
|
||||
favoriteUserId: Int?
|
||||
explore: Boolean?,
|
||||
favoriteUserId: Int?,
|
||||
): ListContainer<MomentEntity> {
|
||||
return momentBackend.fetchMomentItems(
|
||||
pageNumber = pageNumber,
|
||||
@@ -96,7 +101,8 @@ class MomentServiceImpl() : MomentService {
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch,
|
||||
trend = trend,
|
||||
favoriteUserId = favoriteUserId
|
||||
favoriteUserId = favoriteUserId,
|
||||
explore = explore
|
||||
)
|
||||
}
|
||||
|
||||
@@ -144,6 +150,7 @@ class MomentBackend {
|
||||
timelineId: Int?,
|
||||
contentSearch: String?,
|
||||
trend: Boolean?,
|
||||
explore: Boolean?,
|
||||
favoriteUserId: Int? = null
|
||||
): ListContainer<MomentEntity> {
|
||||
val resp = ApiClient.api.getPosts(
|
||||
@@ -153,7 +160,8 @@ class MomentBackend {
|
||||
authorId = author,
|
||||
contentSearch = contentSearch,
|
||||
trend = if (trend == true) "true" else "",
|
||||
favouriteUserId = favoriteUserId
|
||||
favouriteUserId = favoriteUserId,
|
||||
explore = if (explore == true) "true" else ""
|
||||
)
|
||||
val body = resp.body() ?: throw ServiceException("Failed to get moments")
|
||||
return ListContainer(
|
||||
|
||||
Reference in New Issue
Block a user