Clean up ahead of PR.

pull/1/head
Matthew Chen 7 years ago
parent f5591ef7b7
commit 2b45a8348e

@ -10,6 +10,7 @@
#import "SSKEnvironment.h"
#import "TSContactThread.h"
#import "TSYapDatabaseObject.h"
#import <Reachability/Reachability.h>
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -20,6 +21,8 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection;
@property (nonatomic) Reachability *reachability;
// Should only be accessed on the serialQueue.
@property (nonatomic) BOOL isProcessing;
@ -42,10 +45,17 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
return self;
}
self.reachability = [Reachability reachabilityForInternetConnection];
_dbConnection = primaryStorage.newDatabaseConnection;
OWSSingletonAssert();
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged)
name:kReachabilityChangedNotification
object:nil];
// Start processing.
[AppReadiness runNowOrWhenAppIsReady:^{
[self scheduleProcessing];
@ -96,6 +106,12 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
- (void)process {
OWSLogVerbose(@"Processing outbound delivery receipts.");
if (!self.reachability.isReachable) {
// No network availability; abort.
self.isProcessing = NO;
return;
}
NSMutableDictionary<NSString *, NSSet<NSNumber *> *> *deliveryReceiptMap = [NSMutableDictionary new];
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[transaction enumerateKeysAndObjectsInCollection:kDeliveryReceiptManagerCollection
@ -221,6 +237,12 @@ NSString *const kDeliveryReceiptManagerCollection = @"kDeliveryReceiptManagerCol
});
}
- (void)reachabilityChanged {
OWSAssertIsOnMainThread();
[self scheduleProcessing];
}
@end
NS_ASSUME_NONNULL_END

@ -507,12 +507,6 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (void)sendDeliveryReceiptForEnvelope:(SSKProtoEnvelope *)envelope {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^ {
});
}
- (void)sendGroupInfoRequest:(NSData *)groupId
envelope:(SSKProtoEnvelope *)envelope
transaction:(YapDatabaseReadWriteTransaction *)transaction

Loading…
Cancel
Save