diff --git a/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.h b/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.h index 562608637..1e3428d60 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.h +++ b/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.h @@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly) TSInfoMessageType infoMessageType; @property (nonatomic, readonly) CGFloat mediaViewAlpha; @property (nonatomic, readonly) BOOL isMediaBeingSent; -@property (nonatomic, readonly) BOOL isOutgoingAndSent; @property (nonatomic, readonly) BOOL isOutgoingAndDelivered; @end diff --git a/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.m index 175666f7d..0d9c37f79 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSMessageAdapter.m @@ -351,17 +351,6 @@ return NO; } -- (BOOL)isOutgoingAndSent -{ - if ([self.interaction isKindOfClass:[TSOutgoingMessage class]]) { - TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.interaction; - if (outgoingMessage.messageState == TSOutgoingMessageStateSent) { - return YES; - } - } - return NO; -} - - (BOOL)isOutgoingAndDelivered { if ([self.interaction isKindOfClass:[TSOutgoingMessage class]]) { diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index c13485773..95a49864c 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -1248,20 +1248,17 @@ typedef enum : NSUInteger { return !![self collectionView:self.collectionView attributedTextForCellBottomLabelAtIndexPath:indexPath]; } -- (id)nextOutgoingMessage:(NSIndexPath *)indexPath +- (TSOutgoingMessage *)nextOutgoingMessage:(NSIndexPath *)indexPath { - id nextMessage = - [self messageAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section]]; - int i = 1; - - while (indexPath.item + i < [self.collectionView numberOfItemsInSection:indexPath.section] - 1 - && !nextMessage.isOutgoingAndDelivered) { - i++; - nextMessage = - [self messageAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row + i inSection:indexPath.section]]; + NSInteger rowCount = [self.collectionView numberOfItemsInSection:indexPath.section]; + for (NSInteger row = indexPath.row + 1; row < rowCount; row++) { + id nextMessage = [self messageAtIndexPath:[NSIndexPath indexPathForRow:row + inSection:indexPath.section]]; + if ([nextMessage isKindOfClass:[TSOutgoingMessage class]]) { + return (TSOutgoingMessage *)nextMessage; + } } - - return nextMessage; + return nil; } - (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView @@ -1277,11 +1274,16 @@ typedef enum : NSUInteger { TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)message.interaction; if (outgoingMessage.messageState == TSOutgoingMessageStateUnsent) { return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"FAILED_SENDING_TEXT", nil)]; - } else if (message.isOutgoingAndDelivered || - message.isOutgoingAndSent) { + } else if (outgoingMessage.messageState == TSOutgoingMessageStateSent || + outgoingMessage.messageState == TSOutgoingMessageStateDelivered) { // Show a checkmark icon. + // + // TODO: It'd be nice to distinguish the "sent" and "delivered" states, + // but JSQMessageViewController doesn't give us a great way to do so. + // We don't have a great icon for the "delivered" state, + // we can't kern checkmarks together in a JSQMessageViewController + // "cell bottom label", etc. NSAttributedString *result = - // Show an "..." ellisis icon. [[NSAttributedString alloc] initWithString:@"N" attributes:@{ NSFontAttributeName: [UIFont ows_elegantIconsFont:10.f], @@ -1293,13 +1295,23 @@ typedef enum : NSUInteger { return result; } - // Or when the next message is *not* an outgoing delivered message. - TSMessageAdapter *nextMessage = [self nextOutgoingMessage:indexPath]; - if (!nextMessage.isOutgoingAndDelivered) { + // Or when the next message is *not* an outgoing sent/delivered message. + TSOutgoingMessage *nextMessage = [self nextOutgoingMessage:indexPath]; + if (nextMessage && + nextMessage.messageState != TSOutgoingMessageStateSent && + nextMessage.messageState != TSOutgoingMessageStateDelivered) { [self updateLastDeliveredMessage:message]; return result; } } else if (message.isMediaBeingSent) { + return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"UPLOADING_MESSAGE_TEXT", + @"message footer while attachment is uploading")]; + } else { + OWSAssert(outgoingMessage.messageState == TSOutgoingMessageStateAttemptingOut); + // Show an "..." ellisis icon. + // + // TODO: It'd be nice to animate this, but JSQMessageViewController doesn't give us a great way to do so. + // We already have problems with unstable cell layout; we don't want to exacerbate them. NSAttributedString *result = [[NSAttributedString alloc] initWithString:@"/" attributes:@{ diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index accbe0c8c..9eaba0f3d 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -979,6 +979,9 @@ /* No comment provided by engineer. */ "Upgrading Signal ..." = "Upgrading Signal ..."; +/* message footer while attachment is uploading */ +"UPLOADING_MESSAGE_TEXT" = "Uploading..."; + /* button text for back button on verification view */ "VERIFICATION_BACK_BUTTON" = "Back";