From 9eca118d8570791a601f0db214b66924b260db94 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 2 Sep 2024 12:07:58 +1000 Subject: [PATCH] Correctly show the 'uploading' state, removed unused function --- .../Message Cells/VisibleMessageCell.swift | 3 +- .../MessageInfoScreen.swift | 3 +- Session/Shared/FullConversationCell.swift | 3 +- .../Database/Models/RecipientState.swift | 56 +++++++------------ 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 3f3df84c6..d20a35d79 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -395,7 +395,8 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { // Message status image view let (image, statusText, tintColor) = cellViewModel.state.statusIconInfo( variant: cellViewModel.variant, - hasAtLeastOneReadReceipt: cellViewModel.hasAtLeastOneReadReceipt + hasAtLeastOneReadReceipt: cellViewModel.hasAtLeastOneReadReceipt, + hasAttachments: (cellViewModel.attachments?.isEmpty == false) ) messageStatusLabel.text = statusText messageStatusLabel.themeTextColor = tintColor diff --git a/Session/Media Viewing & Editing/MessageInfoScreen.swift b/Session/Media Viewing & Editing/MessageInfoScreen.swift index 0ac947076..73d57266d 100644 --- a/Session/Media Viewing & Editing/MessageInfoScreen.swift +++ b/Session/Media Viewing & Editing/MessageInfoScreen.swift @@ -52,7 +52,8 @@ struct MessageInfoScreen: View { if isMessageFailed { let (image, statusText, tintColor) = messageViewModel.state.statusIconInfo( variant: messageViewModel.variant, - hasAtLeastOneReadReceipt: messageViewModel.hasAtLeastOneReadReceipt + hasAtLeastOneReadReceipt: messageViewModel.hasAtLeastOneReadReceipt, + hasAttachments: (messageViewModel.attachments?.isEmpty == false) ) HStack(spacing: 6) { diff --git a/Session/Shared/FullConversationCell.swift b/Session/Shared/FullConversationCell.swift index 78ee3d96a..151e6ae52 100644 --- a/Session/Shared/FullConversationCell.swift +++ b/Session/Shared/FullConversationCell.swift @@ -493,7 +493,8 @@ public final class FullConversationCell: UITableViewCell, SwipeActionOptimisticC let stateInfo = cellViewModel.interactionState?.statusIconInfo( variant: (cellViewModel.interactionVariant ?? .standardOutgoing), - hasAtLeastOneReadReceipt: (cellViewModel.interactionHasAtLeastOneReadReceipt ?? false) + hasAtLeastOneReadReceipt: (cellViewModel.interactionHasAtLeastOneReadReceipt ?? false), + hasAttachments: ((cellViewModel.interactionAttachmentCount ?? 0) > 0) ) statusIndicatorView.image = stateInfo?.image statusIndicatorView.themeTintColor = stateInfo?.themeTintColor diff --git a/SessionMessagingKit/Database/Models/RecipientState.swift b/SessionMessagingKit/Database/Models/RecipientState.swift index a3ef26a3e..0ce7a608c 100644 --- a/SessionMessagingKit/Database/Models/RecipientState.swift +++ b/SessionMessagingKit/Database/Models/RecipientState.swift @@ -42,73 +42,59 @@ public struct RecipientState: Codable, Equatable, FetchableRecord, PersistableRe case failedToSync // One-to-one Only case syncing // One-to-one Only - func message(hasAttachments: Bool, hasAtLeastOneReadReceipt: Bool) -> String { - switch self { - case .sending: - guard hasAttachments else { - return "sending".localized() - } - - return "uploading".localized() - - case .failed: return "messageStatusFailedToSend".localized() - - case .sent: - guard hasAtLeastOneReadReceipt else { - return "disappearingMessagesSent".localized() - } - - return "read".localized() - - case .failedToSync: return "messageStatusFailedToSync".localized() - case .syncing: return "messageStatusSyncing".localized() - - default: - Log.error("Message has unexpected status: \(self).") - return "disappearingMessagesSent".localized() + public func statusIconInfo( + variant: Interaction.Variant, + hasAtLeastOneReadReceipt: Bool, + hasAttachments: Bool + ) -> (image: UIImage?, text: String?, themeTintColor: ThemeValue) { + guard variant == .standardOutgoing else { + return (nil, "read".localized(), .messageBubble_deliveryStatus) } - } - - public func statusIconInfo(variant: Interaction.Variant, hasAtLeastOneReadReceipt: Bool) -> (image: UIImage?, text: String?, themeTintColor: ThemeValue) { - guard variant == .standardOutgoing else { return (nil, "read".localized(), .messageBubble_deliveryStatus) } - switch (self, hasAtLeastOneReadReceipt) { - case (.sending, _): + switch (self, hasAtLeastOneReadReceipt, hasAttachments) { + case (.sending, _, true): + return ( + UIImage(systemName: "ellipsis.circle"), + "uploading".localized(), + .messageBubble_deliveryStatus + ) + + case (.sending, _, _): return ( UIImage(systemName: "ellipsis.circle"), "sending".localized(), .messageBubble_deliveryStatus ) - case (.sent, false), (.skipped, _): + case (.sent, false, _), (.skipped, _, _): return ( UIImage(systemName: "checkmark.circle"), "disappearingMessagesSent".localized(), .messageBubble_deliveryStatus ) - case (.sent, true): + case (.sent, true, _): return ( UIImage(systemName: "eye.fill"), "read".localized(), .messageBubble_deliveryStatus ) - case (.failed, _): + case (.failed, _, _): return ( UIImage(systemName: "exclamationmark.triangle"), "messageStatusFailedToSend".localized(), .danger ) - case (.failedToSync, _): + case (.failedToSync, _, _): return ( UIImage(systemName: "exclamationmark.triangle"), "messageStatusFailedToSync".localized(), .warning ) - case (.syncing, _): + case (.syncing, _, _): return ( UIImage(systemName: "ellipsis.circle"), "messageStatusSyncing".localized(),