|
|
@ -19,6 +19,8 @@ NSString *const kTSStorageManagerOWSContactsSyncingLastMessageKey =
|
|
|
|
|
|
|
|
|
|
|
|
@interface OWSContactsSyncing ()
|
|
|
|
@interface OWSContactsSyncing ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) dispatch_queue_t serialQueue;
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
|
|
|
|
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
|
|
|
|
@property (nonatomic, readonly) OWSMessageSender *messageSender;
|
|
|
|
@property (nonatomic, readonly) OWSMessageSender *messageSender;
|
|
|
|
@property (nonatomic) BOOL isRequestInFlight;
|
|
|
|
@property (nonatomic) BOOL isRequestInFlight;
|
|
|
@ -70,6 +72,12 @@ NSString *const kTSStorageManagerOWSContactsSyncingLastMessageKey =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
AssertIsOnMainThread();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!self.serialQueue) {
|
|
|
|
|
|
|
|
_serialQueue = dispatch_queue_create("org.whispersystems.contacts.syncing", DISPATCH_QUEUE_SERIAL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
|
|
|
|
|
|
|
|
if (self.isRequestInFlight) {
|
|
|
|
if (self.isRequestInFlight) {
|
|
|
|
// De-bounce. It's okay if we ignore some new changes;
|
|
|
|
// De-bounce. It's okay if we ignore some new changes;
|
|
|
|
// `sendSyncContactsMessageIfPossible` is called fairly
|
|
|
|
// `sendSyncContactsMessageIfPossible` is called fairly
|
|
|
@ -103,17 +111,18 @@ NSString *const kTSStorageManagerOWSContactsSyncingLastMessageKey =
|
|
|
|
forKey:kTSStorageManagerOWSContactsSyncingLastMessageKey
|
|
|
|
forKey:kTSStorageManagerOWSContactsSyncingLastMessageKey
|
|
|
|
inCollection:kTSStorageManagerOWSContactsSyncingCollection];
|
|
|
|
inCollection:kTSStorageManagerOWSContactsSyncingCollection];
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
self.isRequestInFlight = NO;
|
|
|
|
self.isRequestInFlight = NO;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
DDLogError(@"%@ Failed to send contacts sync message with error: %@", self.tag, error);
|
|
|
|
DDLogError(@"%@ Failed to send contacts sync message with error: %@", self.tag, error);
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
self.isRequestInFlight = NO;
|
|
|
|
self.isRequestInFlight = NO;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)sendSyncContactsMessageIfPossible
|
|
|
|
- (void)sendSyncContactsMessageIfPossible
|
|
|
|