mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 02:47:34 +01:00
fix(inbox): fix mark reply read
This commit is contained in:
parent
c2b245f4ec
commit
fb7723a178
@ -0,0 +1,10 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.api.dto
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CommentReplyResponse(
|
||||
@SerialName("comment_reply_view")
|
||||
val commentReplyView: CommentReplyView,
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.api.dto
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class MarkCommentReplyAsReadForm(
|
||||
@SerialName("comment_reply_id")
|
||||
val replyId: CommentReplyId,
|
||||
@SerialName("read")
|
||||
val read: Boolean,
|
||||
@SerialName("auth")
|
||||
val auth: String,
|
||||
)
|
@ -1,10 +1,12 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.api.service
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.CommentReplyResponse
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.CommentSortType
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetPersonDetailsResponse
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetPersonMentionsResponse
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetRepliesResponse
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkAllAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkCommentReplyAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkPersonMentionAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.PersonMentionResponse
|
||||
import de.jensklingenberg.ktorfit.Response
|
||||
@ -53,4 +55,8 @@ interface UserService {
|
||||
@POST("user/mention/mark_as_read")
|
||||
@Headers("Content-Type: application/json")
|
||||
suspend fun markPersonMentionAsRead(@Body form: MarkPersonMentionAsReadForm): Response<PersonMentionResponse>
|
||||
|
||||
@POST("comment/mark_as_read")
|
||||
@Headers("Content-Type: application/json")
|
||||
suspend fun markCommentReplyAsRead(@Body form: MarkCommentReplyAsReadForm): Response<CommentReplyResponse>
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkAllAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkCommentReplyAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.MarkPersonMentionAsReadForm
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.provider.ServiceProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommentModel
|
||||
@ -117,7 +118,7 @@ class UserRepository(
|
||||
serviceProvider.user.markAllAsRead(data)
|
||||
}
|
||||
|
||||
suspend fun setRead(read: Boolean, mentionId: Int, auth: String? = null) {
|
||||
suspend fun setMentionRead(read: Boolean, mentionId: Int, auth: String? = null) {
|
||||
val data = MarkPersonMentionAsReadForm(
|
||||
mentionId = mentionId,
|
||||
read = read,
|
||||
@ -125,4 +126,13 @@ class UserRepository(
|
||||
)
|
||||
serviceProvider.user.markPersonMentionAsRead(data)
|
||||
}
|
||||
|
||||
suspend fun setReplyRead(read: Boolean, replyId: Int, auth: String? = null) {
|
||||
val data = MarkCommentReplyAsReadForm(
|
||||
replyId = replyId,
|
||||
read = read,
|
||||
auth = auth.orEmpty(),
|
||||
)
|
||||
serviceProvider.user.markCommentReplyAsRead(data)
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class InboxMentionsViewModel(
|
||||
private fun markAsRead(read: Boolean, mentionId: Int) {
|
||||
val auth = identityRepository.authToken.value
|
||||
mvi.scope.launch(Dispatchers.IO) {
|
||||
userRepository.setRead(
|
||||
userRepository.setMentionRead(
|
||||
read = read,
|
||||
mentionId = mentionId,
|
||||
auth = auth,
|
||||
|
@ -33,7 +33,7 @@ class InboxRepliesViewModel(
|
||||
}
|
||||
|
||||
is InboxRepliesMviModel.Intent.MarkMentionAsRead -> {
|
||||
markAsRead(read = intent.read, mentionId = intent.mentionId)
|
||||
markAsRead(read = intent.read, replyId = intent.mentionId)
|
||||
}
|
||||
|
||||
InboxRepliesMviModel.Intent.HapticIndication -> hapticFeedback.vibrate()
|
||||
@ -92,12 +92,12 @@ class InboxRepliesViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun markAsRead(read: Boolean, mentionId: Int) {
|
||||
private fun markAsRead(read: Boolean, replyId: Int) {
|
||||
val auth = identityRepository.authToken.value
|
||||
mvi.scope.launch(Dispatchers.IO) {
|
||||
userRepository.setRead(
|
||||
userRepository.setReplyRead(
|
||||
read = read,
|
||||
mentionId = mentionId,
|
||||
replyId = replyId,
|
||||
auth = auth,
|
||||
)
|
||||
refresh()
|
||||
|
Loading…
x
Reference in New Issue
Block a user