|
|
|
@ -178,7 +178,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
object:nil];
|
|
|
|
|
|
|
|
|
|
// Try to start processing.
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
[self scheduleProcessing];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -198,12 +198,10 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
// Schedules a processing pass, unless one is already scheduled.
|
|
|
|
|
- (void)scheduleProcessing
|
|
|
|
|
{
|
|
|
|
|
DispatchMainThreadSafe(^{
|
|
|
|
|
@synchronized(self)
|
|
|
|
|
{
|
|
|
|
|
if ([TSDatabaseView hasPendingViewRegistrations]) {
|
|
|
|
|
DDLogInfo(
|
|
|
|
|
@"%@ Deferring read receipt processing due to pending database view registrations.", self.tag);
|
|
|
|
|
DDLogInfo(@"%@ Deferring read receipt processing due to pending database view registrations.", self.tag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (self.isProcessing) {
|
|
|
|
@ -224,7 +222,6 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
[self process];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)process
|
|
|
|
@ -241,7 +238,6 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
OWSReadReceiptsForLinkedDevicesMessage *message =
|
|
|
|
|
[[OWSReadReceiptsForLinkedDevicesMessage alloc] initWithReadReceipts:readReceiptsForLinkedDevices];
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
[self.messageSender sendMessage:message
|
|
|
|
|
success:^{
|
|
|
|
|
DDLogInfo(@"%@ Successfully sent %zd read receipt to linked devices.",
|
|
|
|
@ -251,7 +247,6 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
|
DDLogError(@"%@ Failed to send read receipt to linked devices with error: %@", self.tag, error);
|
|
|
|
|
}];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSArray<OWSReadReceipt *> *readReceiptsToSend = [self.toLinkedDevicesReadReceiptMap allValues];
|
|
|
|
@ -266,17 +261,14 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
[[OWSReadReceiptsForSenderMessage alloc] initWithThread:thread
|
|
|
|
|
messageTimestamps:timestamps.allObjects];
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
[self.messageSender sendMessage:message
|
|
|
|
|
success:^{
|
|
|
|
|
DDLogInfo(@"%@ Successfully sent %zd read receipts to sender.",
|
|
|
|
|
self.tag,
|
|
|
|
|
readReceiptsToSend.count);
|
|
|
|
|
DDLogInfo(
|
|
|
|
|
@"%@ Successfully sent %zd read receipts to sender.", self.tag, readReceiptsToSend.count);
|
|
|
|
|
}
|
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
|
DDLogError(@"%@ Failed to send read receipts to sender with error: %@", self.tag, error);
|
|
|
|
|
}];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
[self.toSenderReadReceiptMap removeAllObjects];
|
|
|
|
|
}
|
|
|
|
|