forked from melod1n/fast-messenger
feat(messages): Implement reply functionality
This commit introduces the ability to reply to messages. - **API & Data Layer:** - Replaced `replyTo` parameter with `forward` in `sendMessage` calls across the data, domain, and repository layers to support the new reply mechanism. - **ViewModel:** - Added logic to handle the reply state, including storing the replied message's ID (`replyToCmId`). - When a message is sent, it now correctly constructs a `forward` JSON object if it is a reply. - The UI state (`MessagesHistoryScreenState`) is updated to show and hide the reply preview. - Added a `onReplyCloseClicked` handler to cancel a reply. - The ViewModel interface was removed, and the implementation class `MessagesHistoryViewModelImpl` is used directly. - **UI (Compose):** - A new `ReplyContainer` is displayed above the message input bar when a reply is active. - The input bar's corner radius animates to integrate with the reply container. - Added a `FocusRequester` to automatically focus the input field when the reply action is selected. - Added spacing in the message list to prevent the reply preview from overlapping messages. - The message options dialog now passes the `messageId` and `cmId` when an option is picked.
This commit is contained in:
@@ -32,7 +32,7 @@ interface MessagesRepository {
|
||||
peerId: Long,
|
||||
randomId: Long,
|
||||
message: String?,
|
||||
replyTo: Long?,
|
||||
forward: String?,
|
||||
attachments: List<VkAttachment>?,
|
||||
formatData: VkMessage.FormatData?
|
||||
): ApiResult<MessagesSendResponse, RestApiErrorDomain>
|
||||
|
||||
+2
-2
@@ -195,7 +195,7 @@ class MessagesRepositoryImpl(
|
||||
peerId: Long,
|
||||
randomId: Long,
|
||||
message: String?,
|
||||
replyTo: Long?,
|
||||
forward: String?,
|
||||
attachments: List<VkAttachment>?,
|
||||
formatData: VkMessage.FormatData?
|
||||
): ApiResult<MessagesSendResponse, RestApiErrorDomain> = withContext(Dispatchers.IO) {
|
||||
@@ -203,7 +203,7 @@ class MessagesRepositoryImpl(
|
||||
peerId = peerId,
|
||||
randomId = randomId,
|
||||
message = message,
|
||||
replyTo = replyTo,
|
||||
forward = forward,
|
||||
attachments = attachments,
|
||||
formatData = formatData
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ interface MessagesUseCase : BaseUseCase {
|
||||
peerId: Long,
|
||||
randomId: Long,
|
||||
message: String?,
|
||||
replyTo: Long?,
|
||||
forward: String?,
|
||||
attachments: List<VkAttachment>?,
|
||||
formatData: VkMessage.FormatData?
|
||||
): Flow<State<MessagesSendResponse>>
|
||||
|
||||
@@ -56,7 +56,7 @@ class MessagesUseCaseImpl(
|
||||
peerId: Long,
|
||||
randomId: Long,
|
||||
message: String?,
|
||||
replyTo: Long?,
|
||||
forward: String?,
|
||||
attachments: List<VkAttachment>?,
|
||||
formatData: VkMessage.FormatData?
|
||||
): Flow<State<MessagesSendResponse>> = flowNewState {
|
||||
@@ -64,7 +64,7 @@ class MessagesUseCaseImpl(
|
||||
peerId = peerId,
|
||||
randomId = randomId,
|
||||
message = message,
|
||||
replyTo = replyTo,
|
||||
forward = forward,
|
||||
attachments = attachments,
|
||||
formatData = formatData
|
||||
).mapToState()
|
||||
|
||||
@@ -34,7 +34,7 @@ data class MessagesSendRequest(
|
||||
val message: String?,
|
||||
val lat: Int? = null,
|
||||
val lon: Int? = null,
|
||||
val replyTo: Long? = null,
|
||||
val forward: String? = null,
|
||||
val stickerId: Long? = null,
|
||||
val disableMentions: Boolean? = null,
|
||||
val doNotParseLinks: Boolean? = null,
|
||||
@@ -51,7 +51,7 @@ data class MessagesSendRequest(
|
||||
message?.let { this["message"] = it }
|
||||
lat?.let { this["lat"] = it.toString() }
|
||||
lon?.let { this["lon"] = it.toString() }
|
||||
replyTo?.let { this["reply_to"] = it.toString() }
|
||||
forward?.let { this["forward"] = it }
|
||||
stickerId?.let { this["sticker_id"] = it.toString() }
|
||||
disableMentions?.let { this["disable_mentions"] = it.asInt().toString() }
|
||||
doNotParseLinks?.let { this["dont_parse_links"] = it.asInt().toString() }
|
||||
|
||||
Reference in New Issue
Block a user