Adjust debug UI for creating groups

This commit is contained in:
Sasha Weiss 2023-04-10 10:49:14 -07:00 committed by GitHub
parent 64e396bd1a
commit 40c46d8882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 17 deletions

View File

@ -3649,21 +3649,6 @@ typedef OWSContact * (^OWSContactBlock)(SDSAnyWriteTransaction *transaction);
return randomText;
}
+ (NSString *)randomShortText
{
NSArray<NSString *> *randomTexts = @[
@"a",
@"b",
@"c",
@"d",
@"e",
@"f",
@"g",
];
NSString *randomText = randomTexts[(NSUInteger)arc4random_uniform((uint32_t)randomTexts.count)];
return randomText;
}
+ (void)createFakeThreads:(NSUInteger)threadCount withFakeMessages:(NSUInteger)messageCount
{
[DebugContactsUtils
@ -3866,13 +3851,13 @@ typedef OWSContact * (^OWSContactBlock)(SDSAnyWriteTransaction *transaction);
persistenceCompletionHandler:nil
transaction:transaction];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self createNewGroups:counter - 1 recipientAddress:recipientAddress];
});
});
};
NSString *groupName = [NSUUID UUID].UUIDString;
NSString *groupName = [self randomShortText];
[self createRandomGroupWithName:groupName member:recipientAddress success:completion];
}

View File

@ -49,4 +49,24 @@ public extension DebugUIMessages {
}
}
// MARK: - Random text
extension DebugUIMessages {
private static let shortTextLength: UInt = 4
@objc
static func randomShortText() -> String {
let alphabet: [Character] = (97...122).map { (ascii: Int) in
Character(Unicode.Scalar(ascii)!)
}
let chars: [Character] = (0..<shortTextLength).map { _ in
let index = UInt.random(in: 0..<UInt(alphabet.count))
return alphabet[Int(index)]
}
return String(chars)
}
}
#endif