From 282230c87a6e921fd97f3ea4bfcfda1cccac006c Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 8 Mar 2023 17:10:21 +1100 Subject: [PATCH] minor refactor --- .../Message Cells/InfoMessageCell.swift | 1 + Session/Shared/FullConversationCell.swift | 2 +- .../Database/Models/Interaction.swift | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Session/Conversations/Message Cells/InfoMessageCell.swift b/Session/Conversations/Message Cells/InfoMessageCell.swift index 7c4a90248..c1f7e63a1 100644 --- a/Session/Conversations/Message Cells/InfoMessageCell.swift +++ b/Session/Conversations/Message Cells/InfoMessageCell.swift @@ -97,6 +97,7 @@ final class InfoMessageCell: MessageCell { iconImageViewHeightConstraint.constant = (icon != nil) ? InfoMessageCell.iconSize : 0 self.label.text = cellViewModel.body + self.label.themeTextColor = (cellViewModel.variant == .infoClosedGroupCurrentUserErrorLeaving) ? .danger : .textPrimary } override func dynamicUpdate(with cellViewModel: MessageViewModel, playbackInfo: ConversationViewModel.PlaybackInfo?) { diff --git a/Session/Shared/FullConversationCell.swift b/Session/Shared/FullConversationCell.swift index 0b9ce6e9f..9d23bf031 100644 --- a/Session/Shared/FullConversationCell.swift +++ b/Session/Shared/FullConversationCell.swift @@ -493,7 +493,7 @@ public final class FullConversationCell: UITableViewCell { if (cellViewModel.threadVariant == .closedGroup || cellViewModel.threadVariant == .openGroup) && - (![Interaction.Variant.infoClosedGroupCurrentUserErrorLeaving, Interaction.Variant.infoClosedGroupCurrentUserLeaving].contains(cellViewModel.interactionVariant)) + (cellViewModel.interactionVariant?.isGroupControlMessage == false) { let authorName: String = cellViewModel.authorName(for: cellViewModel.threadVariant) diff --git a/SessionMessagingKit/Database/Models/Interaction.swift b/SessionMessagingKit/Database/Models/Interaction.swift index f12b5af46..6ec1f1542 100644 --- a/SessionMessagingKit/Database/Models/Interaction.swift +++ b/SessionMessagingKit/Database/Models/Interaction.swift @@ -89,7 +89,7 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu public var isInfoMessage: Bool { switch self { - case .infoClosedGroupCreated, .infoClosedGroupUpdated, + case .infoClosedGroupCreated, .infoClosedGroupUpdated, .infoClosedGroupCurrentUserLeft, .infoClosedGroupCurrentUserLeaving, .infoClosedGroupCurrentUserErrorLeaving, .infoDisappearingMessagesUpdate, .infoScreenshotNotification, .infoMediaSavedNotification, .infoMessageRequestAccepted, .infoCall: @@ -100,6 +100,16 @@ public struct Interaction: Codable, Identifiable, Equatable, FetchableRecord, Mu } } + public var isGroupControlMessage: Bool { + switch self { + case .infoClosedGroupCreated, .infoClosedGroupUpdated, + .infoClosedGroupCurrentUserLeft, .infoClosedGroupCurrentUserLeaving, .infoClosedGroupCurrentUserErrorLeaving: + return true + default: + return false + } + } + /// This flag controls whether the `wasRead` flag is automatically set to true based on the message variant (as a result it they will /// or won't affect the unread count) fileprivate var canBeUnread: Bool {