|
|
@ -19,7 +19,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@interface ContactsViewHelper ()
|
|
|
|
@interface ContactsViewHelper () <OWSBlockListCacheDelegate>
|
|
|
|
|
|
|
|
|
|
|
|
// This property is a cached value that is lazy-populated.
|
|
|
|
// This property is a cached value that is lazy-populated.
|
|
|
|
@property (nonatomic, nullable) NSArray<Contact *> *nonSignalContacts;
|
|
|
|
@property (nonatomic, nullable) NSArray<Contact *> *nonSignalContacts;
|
|
|
@ -27,8 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@property (nonatomic) NSDictionary<NSString *, SignalAccount *> *signalAccountMap;
|
|
|
|
@property (nonatomic) NSDictionary<NSString *, SignalAccount *> *signalAccountMap;
|
|
|
|
@property (nonatomic) NSArray<SignalAccount *> *signalAccounts;
|
|
|
|
@property (nonatomic) NSArray<SignalAccount *> *signalAccounts;
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) NSArray<NSString *> *blockedPhoneNumbers;
|
|
|
|
@property (nonatomic, readonly) OWSBlockListCache *blockListCache;
|
|
|
|
@property (nonatomic) NSArray<NSData *> *blockedGroupIds;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts;
|
|
|
|
@property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts;
|
|
|
|
@property (nonatomic) BOOL hasUpdatedContactsAtLeastOnce;
|
|
|
|
@property (nonatomic) BOOL hasUpdatedContactsAtLeastOnce;
|
|
|
@ -52,8 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
_delegate = delegate;
|
|
|
|
_delegate = delegate;
|
|
|
|
|
|
|
|
|
|
|
|
_blockingManager = [OWSBlockingManager sharedManager];
|
|
|
|
_blockingManager = [OWSBlockingManager sharedManager];
|
|
|
|
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
|
|
|
|
_blockListCache = [OWSBlockListCache new];
|
|
|
|
_blockedGroupIds = [_blockingManager blockedGroupIds];
|
|
|
|
[_blockListCache startObservingAndSyncStateWithDelegate:self];
|
|
|
|
|
|
|
|
|
|
|
|
_conversationSearcher = ConversationSearcher.shared;
|
|
|
|
_conversationSearcher = ConversationSearcher.shared;
|
|
|
|
|
|
|
|
|
|
|
@ -76,10 +75,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
selector:@selector(signalAccountsDidChange:)
|
|
|
|
selector:@selector(signalAccountsDidChange:)
|
|
|
|
name:OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
name:OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
selector:@selector(blockListDidChange:)
|
|
|
|
|
|
|
|
name:kNSNotificationName_BlockListDidChange
|
|
|
|
|
|
|
|
object:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
- (void)dealloc
|
|
|
@ -94,16 +89,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[self updateContacts];
|
|
|
|
[self updateContacts];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)blockListDidChange:(NSNotification *)notification
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.blockedPhoneNumbers = self.blockingManager.blockedPhoneNumbers;
|
|
|
|
|
|
|
|
self.blockedGroupIds = self.blockingManager.blockedGroupIds;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self updateContacts];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Contacts
|
|
|
|
#pragma mark - Contacts
|
|
|
|
|
|
|
|
|
|
|
|
- (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
|
|
|
|
- (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
|
|
|
@ -162,14 +147,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
|
|
|
|
|
|
return [_blockedPhoneNumbers containsObject:recipientId];
|
|
|
|
return [self.blockListCache isRecipientIdBlocked:recipientId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)isGroupIdBlocked:(NSData *)groupId
|
|
|
|
- (BOOL)isGroupIdBlocked:(NSData *)groupId
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
|
|
|
|
|
|
return [self.blockedGroupIds containsObject:groupId];
|
|
|
|
return [self.blockListCache isGroupIdBlocked:groupId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)isThreadBlocked:(TSThread *)thread
|
|
|
|
- (BOOL)isThreadBlocked:(TSThread *)thread
|
|
|
@ -434,6 +419,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[fromViewController presentViewController:modal animated:YES completion:nil];
|
|
|
|
[fromViewController presentViewController:modal animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)blockListCacheDidUpdate:(OWSBlockListCache *)blocklistCache
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
|
|
[self updateContacts];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|