Avoid unnecessary write transaction

pull/299/head
nielsandriesse 4 years ago
parent 203959dbab
commit 11d8764db3

@ -5398,13 +5398,13 @@ typedef enum : NSUInteger {
} }
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
__block TSInteraction *targetInteraction; __block TSInteraction *targetInteraction;
[LKStorage writeSyncWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[self.thread enumerateInteractionsWithTransaction:transaction usingBlock:^(TSInteraction *interaction, YapDatabaseReadTransaction *t) { [self.thread enumerateInteractionsWithTransaction:transaction usingBlock:^(TSInteraction *interaction, YapDatabaseReadTransaction *t) {
if (interaction.timestampForUI == timestamp.unsignedLongLongValue) { if (interaction.timestampForUI == timestamp.unsignedLongLongValue) {
targetInteraction = interaction; targetInteraction = interaction;
} }
}]; }];
} error:nil]; }];
if (targetInteraction == nil || targetInteraction.interactionType != OWSInteractionType_OutgoingMessage) { return; } if (targetInteraction == nil || targetInteraction.interactionType != OWSInteractionType_OutgoingMessage) { return; }
NSString *hexEncodedPublicKey = targetInteraction.thread.contactIdentifier; NSString *hexEncodedPublicKey = targetInteraction.thread.contactIdentifier;
if (hexEncodedPublicKey == nil) { return; } if (hexEncodedPublicKey == nil) { return; }

Loading…
Cancel
Save