Correctly show the 'uploading' state, removed unused function

pull/1023/head
Morgan Pretty 7 months ago
parent 3dc0ed255c
commit 9eca118d85

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

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

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

@ -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()
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)
}
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) -> (image: UIImage?, text: String?, themeTintColor: ThemeValue) {
guard variant == .standardOutgoing else { return (nil, "read".localized(), .messageBubble_deliveryStatus) }
switch (self, hasAtLeastOneReadReceipt, hasAttachments) {
case (.sending, _, true):
return (
UIImage(systemName: "ellipsis.circle"),
"uploading".localized(),
.messageBubble_deliveryStatus
)
switch (self, hasAtLeastOneReadReceipt) {
case (.sending, _):
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(),

Loading…
Cancel
Save