|
|
|
@ -128,6 +128,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
actionBlock:^{
|
|
|
|
|
[DebugUIMessages sendFakeMessages:100 * 1000 thread:thread];
|
|
|
|
|
}],
|
|
|
|
|
[OWSTableItem itemWithTitle:@"Create 100k fake text messages"
|
|
|
|
|
actionBlock:^{
|
|
|
|
|
[DebugUIMessages sendFakeMessages:100 * 1000 thread:thread isTextOnly:YES];
|
|
|
|
|
}],
|
|
|
|
|
[OWSTableItem itemWithTitle:@"Create 1 fake unread messages"
|
|
|
|
|
actionBlock:^{
|
|
|
|
|
[DebugUIMessages createFakeUnreadMessages:1 thread:thread];
|
|
|
|
@ -983,27 +987,42 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
+ (void)sendFakeMessages:(NSUInteger)counter thread:(TSThread *)thread
|
|
|
|
|
{
|
|
|
|
|
[self sendFakeMessages:counter thread:thread isTextOnly:NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void)sendFakeMessages:(NSUInteger)counter thread:(TSThread *)thread isTextOnly:(BOOL)isTextOnly
|
|
|
|
|
{
|
|
|
|
|
const NSUInteger kMaxBatchSize = 2500;
|
|
|
|
|
if (counter < kMaxBatchSize) {
|
|
|
|
|
[TSStorageManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[self sendFakeMessages:counter thread:thread isTextOnly:isTextOnly transaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
} else {
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
NSUInteger remainder = counter;
|
|
|
|
|
while (remainder > 0) {
|
|
|
|
|
NSUInteger batchSize = MIN((NSUInteger)2500, remainder);
|
|
|
|
|
NSUInteger batchSize = MIN(kMaxBatchSize, remainder);
|
|
|
|
|
[TSStorageManager.dbReadWriteConnection
|
|
|
|
|
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[self sendFakeMessages:counter thread:thread transaction:transaction];
|
|
|
|
|
[self sendFakeMessages:batchSize thread:thread isTextOnly:isTextOnly transaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
remainder -= batchSize;
|
|
|
|
|
DDLogInfo(@"%@ sendFakeMessages %zd / %zd", self.logTag, counter - remainder, counter);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void)sendFakeMessages:(NSUInteger)counter
|
|
|
|
|
thread:(TSThread *)thread
|
|
|
|
|
isTextOnly:(BOOL)isTextOnly
|
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
{
|
|
|
|
|
DDLogInfo(@"%@ sendFakeMessages: %zd", self.logTag, counter);
|
|
|
|
|
|
|
|
|
|
for (NSUInteger i = 0; i < counter; i++) {
|
|
|
|
|
NSString *randomText = [self randomText];
|
|
|
|
|
switch (arc4random_uniform(4)) {
|
|
|
|
|
switch (arc4random_uniform(isTextOnly ? 2 : 4)) {
|
|
|
|
|
case 0: {
|
|
|
|
|
TSIncomingMessage *message =
|
|
|
|
|
[[TSIncomingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
|
|
|
@ -1038,6 +1057,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
relay:@""
|
|
|
|
|
sourceFilename:@"test.mp3"
|
|
|
|
|
attachmentType:TSAttachmentTypeDefault];
|
|
|
|
|
pointer.state = TSAttachmentPointerStateFailed;
|
|
|
|
|
[pointer saveWithTransaction:transaction];
|
|
|
|
|
TSIncomingMessage *message =
|
|
|
|
|
[[TSIncomingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
|
|
|
@ -1280,7 +1300,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
},
|
|
|
|
|
^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
NSUInteger messageCount = (NSUInteger)(1 + arc4random_uniform(4));
|
|
|
|
|
[self sendFakeMessages:messageCount thread:thread transaction:transaction];
|
|
|
|
|
[self sendFakeMessages:messageCount thread:thread isTextOnly:NO transaction:transaction];
|
|
|
|
|
},
|
|
|
|
|
^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
NSUInteger messageCount = (NSUInteger)(1 + arc4random_uniform(4));
|
|
|
|
|