Merge branch 'mkirk/show-timestamp-after-unread'

This commit is contained in:
Matthew Chen 2017-07-04 09:15:53 -04:00
commit 6e31713c8d
4 changed files with 33 additions and 0 deletions

View file

@ -261,6 +261,7 @@ NS_ASSUME_NONNULL_BEGIN
adapter.outgoingMessageStatus = ((TSOutgoingMessage *)interaction).messageState;
}
OWSAssert(adapter.date);
return adapter;
}

View file

@ -1835,6 +1835,13 @@ typedef enum : NSUInteger {
id<OWSMessageData> previousMessage =
[self messageAtIndexPath:[NSIndexPath indexPathForItem:indexPath.row - 1 inSection:indexPath.section]];
if ([previousMessage.interaction isKindOfClass:[TSUnreadIndicatorInteraction class]]) {
// Always show timestamp between unread indicator and the following interaction
return YES;
}
OWSAssert(currentMessage.date);
OWSAssert(previousMessage.date);
NSTimeInterval timeDifference = [currentMessage.date timeIntervalSinceDate:previousMessage.date];
if (timeDifference > kTSMessageSentDateShowTimeInterval) {
showDate = YES;

View file

@ -77,6 +77,14 @@ NS_ASSUME_NONNULL_BEGIN
actionBlock:^{
[DebugUIMessages sendFakeMessages:10 * 1000 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Create 1 fake unread messages"
actionBlock:^{
[DebugUIMessages createFakeUnreadMessages:1 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Create 10 fake unread messages"
actionBlock:^{
[DebugUIMessages createFakeUnreadMessages:10 thread:thread];
}],
[OWSTableItem itemWithTitle:@"Send text/x-signal-plain"
actionBlock:^{
[DebugUIMessages sendOversizeTextMessage:thread];
@ -780,6 +788,21 @@ NS_ASSUME_NONNULL_BEGIN
return randomText;
}
+ (void)createFakeUnreadMessages:(int)counter thread:(TSThread *)thread
{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
for (int i = 0; i < counter; i++) {
NSString *randomText = [self randomText];
TSIncomingMessage *message = [[TSIncomingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
authorId:@"+19174054215"
sourceDeviceId:0
messageBody:randomText];
[message saveWithTransaction:transaction];
}
}];
}
+ (void)sendFakeMessages:(int)counter thread:(TSThread *)thread
{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {

View file

@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) UIImageView *imageView;
@property (nonatomic) UILabel *titleLabel;
// override from JSQMessagesCollectionViewCell
@property (nonatomic) UILabel *cellTopLabel;
@end