feat(messages): Implement "message read by" counter
This commit introduces the ability to see how many people have read an outgoing message in a group chat. A "views" count is now displayed in the message options dialog for relevant messages. - **API & Data Layer:** - Added `getMessageReadPeers` to `MessagesService` and `MessagesRepository` to fetch users who have read a specific message. - Introduced `MessagesGetReadPeersResponse` to handle the API response. - A new URL constant `GET_MESSAGE_READ_PEERS` was added. - **Domain Layer:** - A new `GetMessageReadPeersUseCase` is created to provide the view count to the ViewModel. - The use case is registered in the `DomainModule`. - **ViewModel:** - `MessagesHistoryViewModel` now includes `loadMessageReadPeers` to asynchronously fetch and return the view count for a message. - **UI (Compose):** - The `MessageOptionsDialog` now displays a "views" count for outgoing chat messages. - It uses a `LaunchedEffect` to call `loadMessageReadPeers` when the dialog is shown. - The `visibility` icon has been updated and its XML file renamed to `round_visibility_24px.xml` to follow a consistent naming convention. - **Refactoring & Minor Fixes:** - Simplified several `derivedStateOf` usages to direct calculations or property delegates in `MessageBubble.kt` and `MessagesList.kt` for minor performance improvements. - Renamed `IncomingMessageBubble.kt` and `OutgoingMessageBubble.kt` to `MessageBubbleIncoming.kt` and `MessageBubbleOutgoing.kt` respectively for consistency. - Removed an unnecessary log statement in `MessagesList.kt`.
This commit is contained in:
@@ -6,6 +6,7 @@ import dev.meloda.fast.model.api.domain.VkAttachment
|
||||
import dev.meloda.fast.model.api.domain.VkAttachmentHistoryMessage
|
||||
import dev.meloda.fast.model.api.domain.VkMessage
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetConversationMembersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetReadPeersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesSendResponse
|
||||
import dev.meloda.fast.network.RestApiErrorDomain
|
||||
|
||||
@@ -110,4 +111,9 @@ interface MessagesRepository {
|
||||
chatId: Long,
|
||||
memberId: Long
|
||||
): ApiResult<Int, RestApiErrorDomain>
|
||||
|
||||
suspend fun getMessageReadPeers(
|
||||
peerId: Long,
|
||||
cmId: Long
|
||||
): ApiResult<MessagesGetReadPeersResponse, RestApiErrorDomain>
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import dev.meloda.fast.model.api.requests.MessagesRemoveChatUserRequest
|
||||
import dev.meloda.fast.model.api.requests.MessagesSendRequest
|
||||
import dev.meloda.fast.model.api.requests.MessagesUnpinMessageRequest
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetConversationMembersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetReadPeersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesSendResponse
|
||||
import dev.meloda.fast.network.RestApiErrorDomain
|
||||
import dev.meloda.fast.network.mapApiDefault
|
||||
@@ -419,4 +420,18 @@ class MessagesRepositoryImpl(
|
||||
|
||||
messagesService.removeChatUser(requestModel.map).mapApiDefault()
|
||||
}
|
||||
|
||||
override suspend fun getMessageReadPeers(
|
||||
peerId: Long,
|
||||
cmId: Long
|
||||
): ApiResult<MessagesGetReadPeersResponse, RestApiErrorDomain> = withContext(Dispatchers.IO) {
|
||||
messagesService.getMessageReadPeers(
|
||||
mapOf(
|
||||
"peer_id" to peerId.toString(),
|
||||
"cmid" to cmId.toString(),
|
||||
"extended" to "1",
|
||||
"fields" to VkConstants.USER_FIELDS
|
||||
)
|
||||
).mapApiDefault()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user