minor refactor

This commit is contained in:
ryanzhao 2023-03-08 17:10:21 +11:00
parent 102b4a67ad
commit 282230c87a
3 changed files with 13 additions and 2 deletions

View File

@ -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?) {

View File

@ -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)

View File

@ -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 {