Skip to content

Commit

Permalink
fix: show last deleted message
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed May 10, 2024
1 parent f6fa504 commit 557755a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ sealed interface MessagePreviewContent {

data class MissedCall(override val username: String?) : WithUser

data class Deleted(override val username: String?) : WithUser
}

data class Ephemeral(val isGroupConversation: Boolean) : MessagePreviewContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ private fun MessagePreviewEntityContent.toMessageContent(): MessagePreviewConten
is MessagePreviewEntityContent.ConversationVerificationDegradedMls -> MessagePreviewContent.VerificationChanged.DegradedMls
is MessagePreviewEntityContent.ConversationVerificationDegradedProteus -> MessagePreviewContent.VerificationChanged.DegradedProteus
is MessagePreviewEntityContent.Location -> MessagePreviewContent.WithUser.Location(username = senderName)
is MessagePreviewEntityContent.Deleted -> MessagePreviewContent.WithUser.Deleted(username = senderName)
}

fun AssetTypeEntity.toModel(): AssetType = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SELECT * FROM MessagePreview AS message
WHERE id IN (
SELECT id FROM Message
WHERE
Message.visibility = 'VISIBLE' AND
Message.visibility IN ('VISIBLE', 'DELETED') AND
Message.content_type IN ('TEXT', 'ASSET', 'KNOCK', 'MISSED_CALL', 'CONVERSATION_RENAMED', 'MEMBER_CHANGE', 'COMPOSITE', 'CONVERSATION_DEGRADED_MLS', 'CONVERSATION_DEGRADED_PROTEUS', 'CONVERSATION_VERIFIED_MLS', 'CONVERSATION_VERIFIED_PROTEUS', 'LOCATION')
GROUP BY Message.conversation_id
HAVING Message.creation_date = MAX(Message.creation_date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ data class NotificationMessageEntity(

sealed class MessagePreviewEntityContent {

data class Deleted(val senderName: String?) : MessagePreviewEntityContent()
data class Text(val senderName: String?, val messageBody: String) : MessagePreviewEntityContent()

data class Composite(val senderName: String?, val messageBody: String?) : MessagePreviewEntityContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ object MessageMapper {
@Suppress("ComplexMethod", "LongMethod")
private fun toMessagePreviewEntityContent(
contentType: MessageEntity.ContentType,
visibility: MessageEntity.Visibility,
senderName: String?,
isSelfMessage: Boolean,
memberChangeList: List<QualifiedIDEntity>?,
Expand All @@ -61,6 +62,7 @@ object MessageMapper {
} else {
mapContentType(
contentType,
visibility,
senderName,
isSelfMessage,
memberChangeList,
Expand All @@ -79,6 +81,7 @@ object MessageMapper {
@Suppress("LongMethod", "ComplexMethod")
private fun mapContentType(
contentType: MessageEntity.ContentType,
visibility: MessageEntity.Visibility,
senderName: String?,
isSelfMessage: Boolean,
memberChangeList: List<QualifiedIDEntity>?,
Expand All @@ -90,6 +93,10 @@ object MessageMapper {
selfUserId: QualifiedIDEntity?,
senderUserId: QualifiedIDEntity?
): MessagePreviewEntityContent {
if(visibility == MessageEntity.Visibility.DELETED) {
return MessagePreviewEntityContent.Deleted(senderName)
}

return when (contentType) {
MessageEntity.ContentType.COMPOSITE -> MessagePreviewEntityContent.Composite(
senderName = senderName,
Expand Down Expand Up @@ -253,6 +260,7 @@ object MessageMapper {
): MessagePreviewEntity {
val content = toMessagePreviewEntityContent(
contentType = contentType,
visibility = visibility,
senderName = senderName,
isSelfMessage = isSelfMessage,
memberChangeList = memberChangeList,
Expand Down

0 comments on commit 557755a

Please sign in to comment.