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 // Message status image view
let (image, statusText, tintColor) = cellViewModel.state.statusIconInfo( let (image, statusText, tintColor) = cellViewModel.state.statusIconInfo(
variant: cellViewModel.variant, variant: cellViewModel.variant,
hasAtLeastOneReadReceipt: cellViewModel.hasAtLeastOneReadReceipt hasAtLeastOneReadReceipt: cellViewModel.hasAtLeastOneReadReceipt,
hasAttachments: (cellViewModel.attachments?.isEmpty == false)
) )
messageStatusLabel.text = statusText messageStatusLabel.text = statusText
messageStatusLabel.themeTextColor = tintColor messageStatusLabel.themeTextColor = tintColor

@ -52,7 +52,8 @@ struct MessageInfoScreen: View {
if isMessageFailed { if isMessageFailed {
let (image, statusText, tintColor) = messageViewModel.state.statusIconInfo( let (image, statusText, tintColor) = messageViewModel.state.statusIconInfo(
variant: messageViewModel.variant, variant: messageViewModel.variant,
hasAtLeastOneReadReceipt: messageViewModel.hasAtLeastOneReadReceipt hasAtLeastOneReadReceipt: messageViewModel.hasAtLeastOneReadReceipt,
hasAttachments: (messageViewModel.attachments?.isEmpty == false)
) )
HStack(spacing: 6) { HStack(spacing: 6) {

@ -493,7 +493,8 @@ public final class FullConversationCell: UITableViewCell, SwipeActionOptimisticC
let stateInfo = cellViewModel.interactionState?.statusIconInfo( let stateInfo = cellViewModel.interactionState?.statusIconInfo(
variant: (cellViewModel.interactionVariant ?? .standardOutgoing), variant: (cellViewModel.interactionVariant ?? .standardOutgoing),
hasAtLeastOneReadReceipt: (cellViewModel.interactionHasAtLeastOneReadReceipt ?? false) hasAtLeastOneReadReceipt: (cellViewModel.interactionHasAtLeastOneReadReceipt ?? false),
hasAttachments: ((cellViewModel.interactionAttachmentCount ?? 0) > 0)
) )
statusIndicatorView.image = stateInfo?.image statusIndicatorView.image = stateInfo?.image
statusIndicatorView.themeTintColor = stateInfo?.themeTintColor statusIndicatorView.themeTintColor = stateInfo?.themeTintColor

@ -42,73 +42,59 @@ public struct RecipientState: Codable, Equatable, FetchableRecord, PersistableRe
case failedToSync // One-to-one Only case failedToSync // One-to-one Only
case syncing // One-to-one Only case syncing // One-to-one Only
func message(hasAttachments: Bool, hasAtLeastOneReadReceipt: Bool) -> String { public func statusIconInfo(
switch self { variant: Interaction.Variant,
case .sending: hasAtLeastOneReadReceipt: Bool,
guard hasAttachments else { hasAttachments: Bool
return "sending".localized() ) -> (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) { switch (self, hasAtLeastOneReadReceipt, hasAttachments) {
case (.sending, _): case (.sending, _, true):
return (
UIImage(systemName: "ellipsis.circle"),
"uploading".localized(),
.messageBubble_deliveryStatus
)
case (.sending, _, _):
return ( return (
UIImage(systemName: "ellipsis.circle"), UIImage(systemName: "ellipsis.circle"),
"sending".localized(), "sending".localized(),
.messageBubble_deliveryStatus .messageBubble_deliveryStatus
) )
case (.sent, false), (.skipped, _): case (.sent, false, _), (.skipped, _, _):
return ( return (
UIImage(systemName: "checkmark.circle"), UIImage(systemName: "checkmark.circle"),
"disappearingMessagesSent".localized(), "disappearingMessagesSent".localized(),
.messageBubble_deliveryStatus .messageBubble_deliveryStatus
) )
case (.sent, true): case (.sent, true, _):
return ( return (
UIImage(systemName: "eye.fill"), UIImage(systemName: "eye.fill"),
"read".localized(), "read".localized(),
.messageBubble_deliveryStatus .messageBubble_deliveryStatus
) )
case (.failed, _): case (.failed, _, _):
return ( return (
UIImage(systemName: "exclamationmark.triangle"), UIImage(systemName: "exclamationmark.triangle"),
"messageStatusFailedToSend".localized(), "messageStatusFailedToSend".localized(),
.danger .danger
) )
case (.failedToSync, _): case (.failedToSync, _, _):
return ( return (
UIImage(systemName: "exclamationmark.triangle"), UIImage(systemName: "exclamationmark.triangle"),
"messageStatusFailedToSync".localized(), "messageStatusFailedToSync".localized(),
.warning .warning
) )
case (.syncing, _): case (.syncing, _, _):
return ( return (
UIImage(systemName: "ellipsis.circle"), UIImage(systemName: "ellipsis.circle"),
"messageStatusSyncing".localized(), "messageStatusSyncing".localized(),

Loading…
Cancel
Save