Fix race condition

pull/190/head
nielsandriesse 5 years ago
parent 6bd8512887
commit 3e8f79f9f3

@ -365,15 +365,13 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.calculatingPoW object:[[NSNumber alloc] initWithUnsignedLongLong:message.timestamp]]; [NSNotificationCenter.defaultCenter postNotificationName:NSNotification.calculatingPoW object:[[NSNumber alloc] initWithUnsignedLongLong:message.timestamp]];
} }
dispatch_async(dispatch_get_main_queue(), ^{ if ([LKFriendRequestProtocol shouldUpdateFriendRequestStatusFromMessage:message]) {
if ([LKFriendRequestProtocol shouldUpdateFriendRequestStatusFromMessage:message]) { [self.primaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[self.primaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { // Loki: Optimistically update friend request status when we can. This is used for
// Loki: Optimistically update friend request status when we can. This is used for // e.g. preventing AFRs from being sent twice on a contact sync.
// e.g. preventing AFRs from being sent twice on a contact sync. [LKFriendRequestProtocol setFriendRequestStatusToSendingIfNeededForHexEncodedPublicKey:message.thread.contactIdentifier transaction:transaction];
[LKFriendRequestProtocol setFriendRequestStatusToSendingIfNeededForHexEncodedPublicKey:message.thread.contactIdentifier transaction:transaction]; }];
}]; }
}
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableArray<NSString *> *allAttachmentIds = [NSMutableArray new]; NSMutableArray<NSString *> *allAttachmentIds = [NSMutableArray new];

Loading…
Cancel
Save