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:
+7
@@ -9,6 +9,7 @@ import dev.meloda.fast.model.api.responses.MessagesGetByIdResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetConversationMembersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetHistoryAttachmentsResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetHistoryResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesGetReadPeersResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesMarkAsImportantResponse
|
||||
import dev.meloda.fast.model.api.responses.MessagesSendResponse
|
||||
import dev.meloda.fast.network.ApiResponse
|
||||
@@ -108,4 +109,10 @@ interface MessagesService {
|
||||
suspend fun removeChatUser(
|
||||
@FieldMap params: Map<String, String>
|
||||
): ApiResult<ApiResponse<Int>, RestApiError>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(MessagesUrls.GET_MESSAGE_READ_PEERS)
|
||||
suspend fun getMessageReadPeers(
|
||||
@FieldMap params: Map<String, String>
|
||||
): ApiResult<ApiResponse<MessagesGetReadPeersResponse>, RestApiError>
|
||||
}
|
||||
|
||||
@@ -22,4 +22,5 @@ object MessagesUrls {
|
||||
const val REMOVE_CHAT_USER = "$URL/messages.removeChatUser"
|
||||
const val GET_HISTORY_ATTACHMENTS = "$URL/messages.getHistoryAttachments"
|
||||
const val CREATE_CHAT = "$URL/messages.createChat"
|
||||
const val GET_MESSAGE_READ_PEERS = "$URL/messages.getMessageReadPeers"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user