Merge branch 'charlesmchen/contactHelperDelegate'

pull/1/head
Matthew Chen 7 years ago
commit 13f4b0ac63

@ -33,8 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[super loadView];
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
self.title
= NSLocalizedString(@"SETTINGS_BLOCK_LIST_TITLE", @"Label for the block list section of the settings view");

@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ContactsViewHelper : NSObject
@property (nonatomic, weak) id<ContactsViewHelperDelegate> delegate;
@property (nonatomic, readonly, weak) id<ContactsViewHelperDelegate> delegate;
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
@property (nonatomic, readonly) OWSBlockingManager *blockingManager;
@ -42,6 +42,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) NSArray<NSString *> *blockedPhoneNumbers;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithDelegate:(id<ContactsViewHelperDelegate>)delegate;
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId;
// This method is faster than OWSBlockingManager but

@ -26,25 +26,33 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSArray<NSString *> *blockedPhoneNumbers;
@property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts;
@end
#pragma mark -
@implementation ContactsViewHelper
- (instancetype)init
- (instancetype)initWithDelegate:(id<ContactsViewHelperDelegate>)delegate
{
self = [super init];
if (!self) {
return self;
}
OWSAssert(delegate);
_delegate = delegate;
_blockingManager = [OWSBlockingManager sharedManager];
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
_contactsManager = [Environment getCurrent].contactsManager;
// We don't want to notify the delegate in the `updateContacts`.
self.shouldNotifyDelegateOfUpdatedContacts = YES;
[self updateContacts];
self.shouldNotifyDelegateOfUpdatedContacts = NO;
[self observeNotifications];
@ -98,7 +106,6 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssert([NSThread isMainThread]);
if ([self.delegate respondsToSelector:@selector(shouldHideLocalNumber)] && [self.delegate shouldHideLocalNumber] &&
[self isCurrentUser:signalAccount]) {
@ -154,7 +161,10 @@ NS_ASSUME_NONNULL_BEGIN
self.signalAccounts = [signalAccounts copy];
self.nonSignalContacts = nil;
[self.delegate contactsViewHelperDidUpdateContacts];
// Don't fire delegate "change" events during initialization.
if (!self.shouldNotifyDelegateOfUpdatedContacts) {
[self.delegate contactsViewHelperDidUpdateContacts];
}
}
- (BOOL)doesSignalAccount:(SignalAccount *)signalAccount matchSearchTerm:(NSString *)searchTerm

@ -56,8 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[super loadView];
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_nonContactAccountSet = [NSMutableSet set];
ReminderView *contactsPermissionReminderView = [[ReminderView alloc]

@ -81,8 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit
{
_messageSender = [Environment getCurrent].messageSender;
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_groupViewHelper = [GroupViewHelper new];
_groupViewHelper.delegate = self;

@ -96,8 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
_contactsManager = [Environment getCurrent].contactsManager;
_messageSender = [Environment getCurrent].messageSender;
_blockingManager = [OWSBlockingManager sharedManager];
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
}
- (NSString *)threadName

@ -58,8 +58,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
self.view.backgroundColor = [UIColor whiteColor];
[self.navigationController.navigationBar setTranslucent:NO];
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
[self createViews];

@ -53,8 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
self.view.backgroundColor = [UIColor whiteColor];
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_threadViewHelper = [ThreadViewHelper new];
_threadViewHelper.delegate = self;

@ -62,8 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit
{
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
}
- (void)configWithThread:(TSGroupThread *)thread

@ -82,8 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit
{
_messageSender = [Environment getCurrent].messageSender;
_contactsViewHelper = [ContactsViewHelper new];
_contactsViewHelper.delegate = self;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_groupViewHelper = [GroupViewHelper new];
_groupViewHelper.delegate = self;

Loading…
Cancel
Save