Merge branch 'charlesmchen/nilSignalAccounts'

pull/1/head
Matthew Chen 7 years ago
commit 6bf0465bcc

@ -55,7 +55,7 @@ class ConversationConfigurationSyncOperation: OWSOperation {
} }
private func sync(contactThread: TSContactThread) { private func sync(contactThread: TSContactThread) {
guard let signalAccount: SignalAccount = self.contactsManager.signalAccount(forRecipientId: contactThread.contactIdentifier()) else { guard let signalAccount: SignalAccount = self.contactsManager.fetchSignalAccount(forRecipientId: contactThread.contactIdentifier()) else {
reportAssertionError(description: "unable to find signalAccount") reportAssertionError(description: "unable to find signalAccount")
return return
} }

@ -83,16 +83,8 @@ NS_ASSUME_NONNULL_BEGIN
[blocklistSection addItem:[OWSTableItem [blocklistSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [cell configureWithRecipientId:phoneNumber
[helper signalAccountForRecipientId:phoneNumber]; contactsManager:helper.contactsManager];
if (signalAccount) {
[cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else {
[cell configureWithRecipientId:phoneNumber
contactsManager:helper.contactsManager];
}
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension

@ -226,7 +226,7 @@ class ConversationSearchViewController: UITableViewController {
owsFail("searchResult was unexpectedly nil") owsFail("searchResult was unexpectedly nil")
return UITableViewCell() return UITableViewCell()
} }
cell.configure(with: searchResult.signalAccount, contactsManager: contactsManager) cell.configure(withRecipientId: searchResult.signalAccount.recipientId, contactsManager: contactsManager)
return cell return cell
case .messages: case .messages:
guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else { guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {

@ -462,8 +462,8 @@ NS_ASSUME_NONNULL_BEGIN
@"An indicator that a contact has been blocked."); @"An indicator that a contact has been blocked.");
} }
[cell configureWithSignalAccount:signalAccount [cell configureWithRecipientId:signalAccount.recipientId
contactsManager:self.contactsViewHelper.contactsManager]; contactsManager:self.contactsViewHelper.contactsManager];
return cell; return cell;
} }
@ -510,15 +510,7 @@ NS_ASSUME_NONNULL_BEGIN
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber];
if (signalAccount) {
[cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else {
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
}
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
@ -566,7 +558,8 @@ NS_ASSUME_NONNULL_BEGIN
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithRecipientId:signalAccount.recipientId
contactsManager:helper.contactsManager];
return cell; return cell;
} }

@ -226,8 +226,6 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount =
[contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isCurrentMember) { if (isCurrentMember) {
@ -239,15 +237,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithRecipientId:recipientId
if (signalAccount) { contactsManager:contactsViewHelper.contactsManager];
[cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager];
} else {
[cell configureWithRecipientId:recipientId
contactsManager:contactsViewHelper.contactsManager];
}
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
@ -335,9 +326,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithSignalAccount:signalAccount [cell configureWithRecipientId:signalAccount.recipientId
contactsManager:contactsViewHelper.contactsManager]; contactsManager:contactsViewHelper.contactsManager];
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension

@ -162,12 +162,12 @@ NS_ASSUME_NONNULL_BEGIN
__weak ShowGroupMembersViewController *weakSelf = self; __weak ShowGroupMembersViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper; ContactsViewHelper *helper = self.contactsViewHelper;
// Sort the group members using contacts manager. // Sort the group members using contacts manager.
NSArray<NSString *> *sortedRecipientIds = NSArray<NSString *> *sortedRecipientIds = [recipientIds sortedArrayUsingComparator:^NSComparisonResult(
[recipientIds sortedArrayUsingComparator:^NSComparisonResult(NSString *recipientIdA, NSString *recipientIdB) { NSString *recipientIdA, NSString *recipientIdB) {
SignalAccount *signalAccountA = [helper.contactsManager signalAccountForRecipientId:recipientIdA]; SignalAccount *signalAccountA = [helper.contactsManager fetchOrBuildSignalAccountForRecipientId:recipientIdA];
SignalAccount *signalAccountB = [helper.contactsManager signalAccountForRecipientId:recipientIdB]; SignalAccount *signalAccountB = [helper.contactsManager fetchOrBuildSignalAccountForRecipientId:recipientIdB];
return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB]; return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB];
}]; }];
for (NSString *recipientId in sortedRecipientIds) { for (NSString *recipientId in sortedRecipientIds) {
[section addItem:[OWSTableItem [section addItem:[OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
@ -175,7 +175,6 @@ NS_ASSUME_NONNULL_BEGIN
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId];
OWSVerificationState verificationState = OWSVerificationState verificationState =
[[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]; [[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId];
BOOL isVerified = verificationState == OWSVerificationStateVerified; BOOL isVerified = verificationState == OWSVerificationStateVerified;
@ -189,12 +188,7 @@ NS_ASSUME_NONNULL_BEGIN
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
if (signalAccount) { [cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
[cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else {
[cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
}
if (isVerified) { if (isVerified) {
[cell setAttributedSubtitle:cell.verifiedSubtitle]; [cell setAttributedSubtitle:cell.verifiedSubtitle];
@ -279,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
ContactsViewHelper *helper = self.contactsViewHelper; ContactsViewHelper *helper = self.contactsViewHelper;
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount = [helper fetchSignalAccountForRecipientId:recipientId];
UIAlertController *actionSheetController = UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

@ -266,7 +266,6 @@ NS_ASSUME_NONNULL_BEGIN
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId]; BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isPreviousMember) { if (isPreviousMember) {
@ -286,19 +285,14 @@ NS_ASSUME_NONNULL_BEGIN
@"An indicator that a user is a new member of the group."); @"An indicator that a user is a new member of the group.");
} }
if (signalAccount) { [cell configureWithRecipientId:recipientId
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager];
contactsManager:contactsViewHelper.contactsManager];
} else {
[cell configureWithRecipientId:recipientId
contactsManager:contactsViewHelper.contactsManager];
}
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount =
[contactsViewHelper fetchSignalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId]; BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isPreviousMember) { if (isPreviousMember) {

@ -682,9 +682,9 @@ private class SignalCallData: NSObject {
// For contacts not stored in our system contacts, we assume they are an unknown caller, and we force // For contacts not stored in our system contacts, we assume they are an unknown caller, and we force
// a TURN connection, so as not to reveal any connectivity information (IP/port) to the caller. // a TURN connection, so as not to reveal any connectivity information (IP/port) to the caller.
let unknownCaller = self.contactsManager.signalAccount(forRecipientId: thread.contactIdentifier()) == nil let isUnknownCaller = !self.contactsManager.hasSignalAccount(forRecipientId: thread.contactIdentifier())
let useTurnOnly = unknownCaller || Environment.current().preferences.doCallsHideIPAddress() let useTurnOnly = isUnknownCaller || Environment.current().preferences.doCallsHideIPAddress()
Logger.debug("\(self.logTag) setting peerConnectionClient in \(#function) for: \(newCall.identifiersForLogs)") Logger.debug("\(self.logTag) setting peerConnectionClient in \(#function) for: \(newCall.identifiersForLogs)")
let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .incoming, useTurnOnly: useTurnOnly) let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .incoming, useTurnOnly: useTurnOnly)

@ -8,15 +8,12 @@ extern const NSUInteger kContactCellAvatarSize;
extern const CGFloat kContactCellAvatarTextMargin; extern const CGFloat kContactCellAvatarTextMargin;
@class OWSContactsManager; @class OWSContactsManager;
@class SignalAccount;
@class TSThread; @class TSThread;
@interface ContactCellView : UIStackView @interface ContactCellView : UIStackView
@property (nonatomic, nullable) NSString *accessoryMessage; @property (nonatomic, nullable) NSString *accessoryMessage;
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;

@ -103,11 +103,6 @@ const CGFloat kContactCellAvatarTextMargin = 12;
self.accessoryLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; self.accessoryLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
} }
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager
{
[self configureWithRecipientId:signalAccount.recipientId contactsManager:contactsManager];
}
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);

@ -7,15 +7,12 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class OWSContactsManager; @class OWSContactsManager;
@class SignalAccount;
@class TSThread; @class TSThread;
@interface ContactTableViewCell : UITableViewCell @interface ContactTableViewCell : UITableViewCell
+ (NSString *)reuseIdentifier; + (NSString *)reuseIdentifier;
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;

@ -53,11 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
self.cellView.userInteractionEnabled = NO; self.cellView.userInteractionEnabled = NO;
} }
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager
{
[self configureWithRecipientId:signalAccount.recipientId contactsManager:contactsManager];
}
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager
{ {
[OWSTableItem configureCell:self]; [OWSTableItem configureCell:self];

@ -55,7 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<ContactsViewHelperDelegate>)delegate; - (instancetype)initWithDelegate:(id<ContactsViewHelperDelegate>)delegate;
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId; - (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId;
- (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId;
// This method is faster than OWSBlockingManager but // This method is faster than OWSBlockingManager but
// is only safe to be called on the main thread. // is only safe to be called on the main thread.

@ -102,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Contacts #pragma mark - Contacts
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId - (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
@ -110,6 +110,14 @@ NS_ASSUME_NONNULL_BEGIN
return self.signalAccountMap[recipientId]; return self.signalAccountMap[recipientId];
} }
- (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return (signalAccount ?: [[SignalAccount alloc] initWithRecipientId:recipientId]);
}
- (BOOL)isSignalAccountHidden:(SignalAccount *)signalAccount - (BOOL)isSignalAccountHidden:(SignalAccount *)signalAccount
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@ -310,7 +318,7 @@ NS_ASSUME_NONNULL_BEGIN
editImmediately:(BOOL)shouldEditImmediately editImmediately:(BOOL)shouldEditImmediately
addToExistingCnContact:(CNContact *_Nullable)existingContact addToExistingCnContact:(CNContact *_Nullable)existingContact
{ {
SignalAccount *signalAccount = [self signalAccountForRecipientId:recipientId]; SignalAccount *signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
if (!self.contactsManager.supportsContactEditing) { if (!self.contactsManager.supportsContactEditing) {
// Should not expose UI that lets the user get here. // Should not expose UI that lets the user get here.

@ -32,7 +32,11 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification;
// order of the signalAccounts array respects the systems contact sorting preference // order of the signalAccounts array respects the systems contact sorting preference
@property (atomic, readonly) NSArray<SignalAccount *> *signalAccounts; @property (atomic, readonly) NSArray<SignalAccount *> *signalAccounts;
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId;
// This will return an instance of SignalAccount for _known_ signal accounts.
- (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId;
// This will always return an instance of SignalAccount.
- (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId;
- (BOOL)hasSignalAccountForRecipientId:(NSString *)recipientId; - (BOOL)hasSignalAccountForRecipientId:(NSString *)recipientId;
- (void)loadSignalAccountsFromCache; - (void)loadSignalAccountsFromCache;

@ -588,7 +588,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
if (!signalAccount) { if (!signalAccount) {
// search system contacts for no-longer-registered signal users, for which there will be no SignalAccount // search system contacts for no-longer-registered signal users, for which there will be no SignalAccount
DDLogDebug(@"%@ no signal account", self.logTag); DDLogDebug(@"%@ no signal account", self.logTag);
@ -616,7 +616,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return signalAccount.contact.firstName.filterStringForDisplay; return signalAccount.contact.firstName.filterStringForDisplay;
} }
@ -624,7 +624,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return signalAccount.contact.lastName.filterStringForDisplay; return signalAccount.contact.lastName.filterStringForDisplay;
} }
@ -821,7 +821,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
} }
// Append unique label for contacts with multiple Signal accounts // Append unique label for contacts with multiple Signal accounts
SignalAccount *signalAccount = [self signalAccountForRecipientId:recipientId]; SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
if (signalAccount && signalAccount.multipleAccountLabelText) { if (signalAccount && signalAccount.multipleAccountLabelText) {
OWSAssert(signalAccount.multipleAccountLabelText.length > 0); OWSAssert(signalAccount.multipleAccountLabelText.length > 0);
@ -938,7 +938,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
return formattedPhoneNumber; return formattedPhoneNumber;
} }
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId - (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
@ -955,11 +955,18 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
return signalAccount; return signalAccount;
} }
- (BOOL)hasSignalAccountForRecipientId:(NSString *)recipientId - (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId
{ {
return [self signalAccountForRecipientId:recipientId] != nil; OWSAssert(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return (signalAccount ?: [[SignalAccount alloc] initWithRecipientId:recipientId]);
} }
- (BOOL)hasSignalAccountForRecipientId:(NSString *)recipientId
{
return [self fetchSignalAccountForRecipientId:recipientId] != nil;
}
- (UIImage *_Nullable)systemContactImageForPhoneIdentifier:(NSString *_Nullable)identifier - (UIImage *_Nullable)systemContactImageForPhoneIdentifier:(NSString *_Nullable)identifier
{ {
@ -971,7 +978,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
if (!contact) { if (!contact) {
// If we haven't loaded system contacts yet, we may have a cached // If we haven't loaded system contacts yet, we may have a cached
// copy in the db // copy in the db
contact = [self signalAccountForRecipientId:identifier].contact; contact = [self fetchSignalAccountForRecipientId:identifier].contact;
} }
return [self avatarImageForCNContactId:contact.cnContactId]; return [self avatarImageForCNContactId:contact.cnContactId];

@ -550,8 +550,8 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
cell.accessoryMessage = cell.accessoryMessage =
[weakSelf.delegate accessoryMessageForSignalAccount:signalAccount]; [weakSelf.delegate accessoryMessageForSignalAccount:signalAccount];
} }
[cell configureWithSignalAccount:signalAccount [cell configureWithRecipientId:signalAccount.recipientId
contactsManager:helper.contactsManager]; contactsManager:helper.contactsManager];
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;

@ -283,7 +283,8 @@ NS_ASSUME_NONNULL_BEGIN
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithRecipientId:signalAccount.recipientId
contactsManager:helper.contactsManager];
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
@ -411,10 +412,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)recipientIdWasSelected:(NSString *)recipientId - (void)recipientIdWasSelected:(NSString *)recipientId
{ {
SignalAccount *_Nullable signalAccount = [self.contactsViewHelper signalAccountForRecipientId:recipientId]; SignalAccount *signalAccount = [self.contactsViewHelper fetchOrBuildSignalAccountForRecipientId:recipientId];
if (!signalAccount) {
signalAccount = [[SignalAccount alloc] initWithRecipientId:recipientId];
}
[self signalAccountWasSelected:signalAccount]; [self signalAccountWasSelected:signalAccount];
} }

Loading…
Cancel
Save