Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Jul 18, 2023
1 parent da4a856 commit e3527ae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ class ProtoContentMapperImpl(

is GenericMessage.Content.ButtonAction -> MessageContent.ButtonAction(
buttonId = protoContent.value.buttonId,
buttonAction = protoContent.value.referenceMessageId
referencedMessageId = protoContent.value.referenceMessageId
)

is GenericMessage.Content.ButtonActionConfirmation -> MessageContent.ButtonActionConfirmation(
referenceMessageId = protoContent.value.referenceMessageId,
referencedMessageId = protoContent.value.referenceMessageId,
buttonId = protoContent.value.buttonId
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,7 @@ internal class MessageInsertExtensionImpl(
message_timer = content.messageTimer
)

is MessageEntityContent.Composite -> {
content.text?.let { text ->
messagesQueries.insertMessageTextContent(
message_id = message.id,
conversation_id = message.conversationId,
text_body = text.messageBody,
quoted_message_id = text.quotedMessageId,
is_quote_verified = text.isQuoteVerified
)
}
content.buttonList.forEach { button ->
buttonContentQueries.insertButton(
message_id = message.id,
conversation_id = message.conversationId,
id = button.id,
text = button.text
)
}
}

is MessageEntityContent.Composite -> insertCompositeMessage(content, message)
is MessageEntityContent.ConversationCreated,
is MessageEntityContent.MLSWrongEpochWarning -> {
/* no-op */
Expand Down Expand Up @@ -335,6 +316,29 @@ internal class MessageInsertExtensionImpl(
}
}

private fun insertCompositeMessage(
content: MessageEntityContent.Composite,
message: MessageEntity
) {
content.text?.let { text ->
messagesQueries.insertMessageTextContent(
message_id = message.id,
conversation_id = message.conversationId,
text_body = text.messageBody,
quoted_message_id = text.quotedMessageId,
is_quote_verified = text.isQuoteVerified
)
}
content.buttonList.forEach { button ->
buttonContentQueries.insertButton(
message_id = message.id,
conversation_id = message.conversationId,
id = button.id,
text = button.text
)
}
}

@Suppress("ComplexMethod")
override fun contentTypeOf(content: MessageEntityContent): MessageEntity.ContentType = when (content) {
is MessageEntityContent.Text -> MessageEntity.ContentType.TEXT
Expand Down

0 comments on commit e3527ae

Please sign in to comment.