diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index ec1400e21..5021d4647 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -403,11 +403,28 @@ typedef enum : NSUInteger { if (indexPath.item == [self.collectionView numberOfItemsInSection:indexPath.section]-1) { return [self isMessageOutgoingAndDelivered:currentMessage]; - + } + + if (![self isMessageOutgoingAndDelivered:currentMessage]) + { + return NO; } + TSMessageAdapter * nextMessage = [self nextOutgoingMessage:indexPath]; + return ![self isMessageOutgoingAndDelivered:nextMessage]; +} + +-(TSMessageAdapter*)nextOutgoingMessage:(NSIndexPath*)indexPath +{ TSMessageAdapter * nextMessage = [self messageAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section]]; - return ![self isMessageOutgoingAndDelivered:nextMessage] && [self isMessageOutgoingAndDelivered:currentMessage]; + int i = 1; + + while (indexPath.item+i < [self.collectionView numberOfItemsInSection:indexPath.section]-1 && ![self isMessageOutgoingAndDelivered:nextMessage]) { + i++; + nextMessage = [self messageAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row+i inSection:indexPath.section]]; + } + + return nextMessage; } -(BOOL)isMessageOutgoingAndDelivered:(TSMessageAdapter*)message