DebugUI: create fake unread messages

helpful for printing unread indicator

// FREEBIE
This commit is contained in:
Michael Kirk 2017-07-01 13:55:07 -07:00 committed by Matthew Chen
parent 7ffb0d98ec
commit bef3a56e50
4 changed files with 28 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,8 @@ typedef enum : NSUInteger {
id<OWSMessageData> previousMessage =
[self messageAtIndexPath:[NSIndexPath indexPathForItem:indexPath.row - 1 inSection:indexPath.section]];
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