Split it based on whether the purpose is “editing” or “sharing”. If we’re editing, it generally means we have full access to contacts, and that we’ve checked which of the contacts are registered on Signal. If we’re “sharing”, we don’t care whether or not they’re registered. If we’re “sharing”, we check whether or not we’ve prompted for the contacts permission yet. If not, we’ll show the prompt. If we’re “editing”, we assume we’ve already prompted (which is already the case today), so `.notDetermined` isn’t a possible state. Other things to note: - The `supportsContactEditing` was always true, so it’s been removed. - The error when contacts access isn’t allowed is now shown more consistently. Previously, it was sometimes shown in response to initializing a view controller. - Some RecipientPickerViewController code was moved from Obj-C to Swift. This is probably useful on its own, but it’ll also make it easier to build some new UI in subsequent commits.
56 lines
1.8 KiB
Objective-C
56 lines
1.8 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 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;
|
|
- (SignalAccount *)fetchOrBuildSignalAccountForAddress:(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;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|