// // Copyright (c) 2019 Open Whisper Systems. All rights reserved. // NS_ASSUME_NONNULL_BEGIN @class Contact; @class ContactsViewHelper; @class SDSAnyReadTransaction; @class SignalAccount; @class TSThread; @protocol ContactsViewHelperDelegate - (void)contactsViewHelperDidUpdateContacts; @optional - (BOOL)shouldHideLocalNumber; @end #pragma mark - @class CNContact; @class CNContactViewController; @class OWSBlockingManager; @class OWSContactsManager; @class OWSProfileManager; @class SignalServiceAddress; @interface ContactsViewHelper : NSObject @property (nonatomic, readonly, weak) id delegate; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) OWSBlockingManager *blockingManager; @property (nonatomic, readonly) OWSProfileManager *profileManager; @property (nonatomic, readonly) NSArray *signalAccounts; // Useful to differentiate between having no signal accounts vs. haven't checked yet @property (nonatomic, readonly) BOOL hasUpdatedContactsAtLeastOnce; // Suitable when the user tries to perform an action which is not possible due to the user having // previously denied contact access. - (void)presentMissingContactAccessAlertControllerFromViewController:(UIViewController *)viewController; - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithDelegate:(id)delegate; - (nullable SignalAccount *)fetchSignalAccountForAddress:(SignalServiceAddress *)address; - (SignalAccount *)fetchOrBuildSignalAccountForAddress:(SignalServiceAddress *)address; // This method is faster than OWSBlockingManager but // is only safe to be called on the main thread. - (BOOL)isSignalServiceAddressBlocked:(SignalServiceAddress *)address; // This method is faster than OWSBlockingManager but // is only safe to be called on the main thread. - (BOOL)isThreadBlocked:(TSThread *)thread; // NOTE: This method uses a transaction. - (SignalServiceAddress *)localAddress; - (NSArray *)signalAccountsMatchingSearchString:(NSString *)searchText transaction:(SDSAnyReadTransaction *)transaction; - (void)warmNonSignalContactsCacheAsync; - (NSArray *)nonSignalContactsMatchingSearchString:(NSString *)searchText; - (nullable CNContactViewController *)contactViewControllerForAddress:(SignalServiceAddress *)address editImmediately:(BOOL)shouldEditImmediately; // This method can be used to edit existing contacts. - (nullable CNContactViewController *)contactViewControllerForAddress:(SignalServiceAddress *)address editImmediately:(BOOL)shouldEditImmediately addToExistingCnContact:(CNContact *_Nullable)existingContact; + (void)presentMissingContactAccessAlertControllerFromViewController:(UIViewController *)viewController; @end NS_ASSUME_NONNULL_END