Signal-iOS/SignalUI/Views/ContactsViewHelper.h
2023-09-06 17:31:16 -05:00

63 lines
2.1 KiB
Objective-C

//
// Copyright 2017 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
NS_ASSUME_NONNULL_BEGIN
@class Contact;
@class ContactsViewHelper;
@class SDSAnyReadTransaction;
@class ServiceIdObjC;
@class SignalAccount;
@class TSThread;
@protocol ContactsViewHelperObserver <NSObject>
- (void)contactsViewHelperDidUpdateContacts;
@end
#pragma mark -
@class CNContact;
@class CNContactViewController;
@class SignalServiceAddress;
@interface ContactsViewHelper : NSObject
// Useful to differentiate between having no signal accounts vs. haven't checked yet
@property (nonatomic, readonly) BOOL hasUpdatedContactsAtLeastOnce;
- (void)addObserver:(id<ContactsViewHelperObserver>)observer NS_SWIFT_NAME(addObserver(_:));
@property (nonatomic, readonly) NSArray<SignalAccount *> *allSignalAccounts;
- (nullable SignalAccount *)fetchSignalAccountForAddress:(SignalServiceAddress *)address;
- (SignalServiceAddress *)localAddress;
- (NSArray<SignalAccount *> *)signalAccountsMatchingSearchString:(NSString *)searchText
transaction:(SDSAnyReadTransaction *)transaction;
- (CNContactViewController *)contactViewControllerForAddress:(SignalServiceAddress *)address
editImmediately:(BOOL)shouldEditImmediately;
// This method can be used to edit existing contacts.
- (CNContactViewController *)contactViewControllerForAddress:(SignalServiceAddress *)address
editImmediately:(BOOL)shouldEditImmediately
addToExistingCnContact:(CNContact *_Nullable)existingContact
updatedNameComponents:(nullable NSPersonNameComponents *)updatedNameComponents;
// Exposed for Swift interop
@property (nonatomic) NSHashTable<id<ContactsViewHelperObserver>> *observers;
@property (nonatomic) NSDictionary<NSString *, SignalAccount *> *phoneNumberSignalAccountMap;
@property (nonatomic) NSDictionary<ServiceIdObjC *, SignalAccount *> *serviceIdSignalAccountMap;
@property (nonatomic) NSArray<SignalAccount *> *signalAccounts;
@end
NS_ASSUME_NONNULL_END