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

Loading…
Cancel
Save