mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 09:58:45 +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
|
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.CommentSortType
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetPersonDetailsResponse
|
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.GetPersonMentionsResponse
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetRepliesResponse
|
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.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.MarkPersonMentionAsReadForm
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.PersonMentionResponse
|
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.PersonMentionResponse
|
||||||
import de.jensklingenberg.ktorfit.Response
|
import de.jensklingenberg.ktorfit.Response
|
||||||
@ -53,4 +55,8 @@ interface UserService {
|
|||||||
@POST("user/mention/mark_as_read")
|
@POST("user/mention/mark_as_read")
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
suspend fun markPersonMentionAsRead(@Body form: MarkPersonMentionAsReadForm): Response<PersonMentionResponse>
|
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
|
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.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.MarkPersonMentionAsReadForm
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.provider.ServiceProvider
|
import com.github.diegoberaldin.raccoonforlemmy.core.api.provider.ServiceProvider
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommentModel
|
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommentModel
|
||||||
@ -117,7 +118,7 @@ class UserRepository(
|
|||||||
serviceProvider.user.markAllAsRead(data)
|
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(
|
val data = MarkPersonMentionAsReadForm(
|
||||||
mentionId = mentionId,
|
mentionId = mentionId,
|
||||||
read = read,
|
read = read,
|
||||||
@ -125,4 +126,13 @@ class UserRepository(
|
|||||||
)
|
)
|
||||||
serviceProvider.user.markPersonMentionAsRead(data)
|
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) {
|
private fun markAsRead(read: Boolean, mentionId: Int) {
|
||||||
val auth = identityRepository.authToken.value
|
val auth = identityRepository.authToken.value
|
||||||
mvi.scope.launch(Dispatchers.IO) {
|
mvi.scope.launch(Dispatchers.IO) {
|
||||||
userRepository.setRead(
|
userRepository.setMentionRead(
|
||||||
read = read,
|
read = read,
|
||||||
mentionId = mentionId,
|
mentionId = mentionId,
|
||||||
auth = auth,
|
auth = auth,
|
||||||
|
@ -33,7 +33,7 @@ class InboxRepliesViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is InboxRepliesMviModel.Intent.MarkMentionAsRead -> {
|
is InboxRepliesMviModel.Intent.MarkMentionAsRead -> {
|
||||||
markAsRead(read = intent.read, mentionId = intent.mentionId)
|
markAsRead(read = intent.read, replyId = intent.mentionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
InboxRepliesMviModel.Intent.HapticIndication -> hapticFeedback.vibrate()
|
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
|
val auth = identityRepository.authToken.value
|
||||||
mvi.scope.launch(Dispatchers.IO) {
|
mvi.scope.launch(Dispatchers.IO) {
|
||||||
userRepository.setRead(
|
userRepository.setReplyRead(
|
||||||
read = read,
|
read = read,
|
||||||
mentionId = mentionId,
|
replyId = replyId,
|
||||||
auth = auth,
|
auth = auth,
|
||||||
)
|
)
|
||||||
refresh()
|
refresh()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user