cambios por api web: deja de enviar lastId al obtener comentarios cuando sea la primera pagina
This commit is contained in:
parent
2bc27cca0c
commit
f6c6d103f6
@ -13,7 +13,7 @@ interface CommentsApi {
|
||||
fun postComment(@Path("postId") postId: Long, @Body commentToPost: CommentToPostDto): Call<CommentDto>
|
||||
|
||||
@GET("Fetch/Post/{postId}/Comments")
|
||||
fun getCommentsOfPosts(@Path("postId") postId: Long, @Query("lastId") lastId: Long, @Query("take") count: Int): Call<FeedCommentsDto>
|
||||
fun getCommentsOfPosts(@Path("postId") postId: Long, @Query("lastId") lastId: Long?, @Query("take") count: Int): Call<FeedCommentsDto>
|
||||
|
||||
@GET("Fetch/Comments/{commentId}")
|
||||
fun getComment(@Path("commentId") commentId: Long): Call<CommentDto>
|
||||
|
||||
@ -14,7 +14,7 @@ import javax.inject.Inject
|
||||
|
||||
class CommentsRepositoryImpl @Inject constructor(private val commentsApi: CommentsApi) :
|
||||
CommentsRepository {
|
||||
override fun getComments(postId: Long, lastId: Long): Flow<Resource<MutableList<Comment>>> = flow {
|
||||
override fun getComments(postId: Long, lastId: Long?): Flow<Resource<MutableList<Comment>>> = flow {
|
||||
try {
|
||||
emit(Resource.Loading())
|
||||
val response = commentsApi.getCommentsOfPosts(postId, lastId, 15).awaitResponse()
|
||||
|
||||
@ -6,7 +6,7 @@ import com.isolaatti.utils.Resource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface CommentsRepository {
|
||||
fun getComments(postId: Long, lastId: Long): Flow<Resource<MutableList<Comment>>>
|
||||
fun getComments(postId: Long, lastId: Long?): Flow<Resource<MutableList<Comment>>>
|
||||
fun getComment(commentId: Long): Flow<Resource<CommentDto>>
|
||||
fun postComment(content: String, audioId: String?, postId: Long): Flow<Resource<Comment>>
|
||||
fun editComment(commentId: Long, content: String, audioId: String?): Flow<Resource<Comment>>
|
||||
|
||||
@ -8,5 +8,5 @@ import javax.inject.Inject
|
||||
|
||||
class GetComments @Inject constructor(private val commentsRepository: CommentsRepository) {
|
||||
operator fun invoke(postId: Long, lastId: Long? = null): Flow<Resource<MutableList<Comment>>> =
|
||||
commentsRepository.getComments(postId, lastId ?: 0)
|
||||
commentsRepository.getComments(postId, lastId)
|
||||
}
|
||||
@ -59,7 +59,7 @@ class CommentsViewModel @Inject constructor(
|
||||
getContent()
|
||||
}
|
||||
|
||||
private var lastId: Long = 0L
|
||||
private var lastId: Long? = null
|
||||
|
||||
fun getContent(refresh: Boolean = false) {
|
||||
viewModelScope.launch {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user