parent
81555d1225
commit
b7c2512eac
|
@ -362,6 +362,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
for (CNLabeledValue *existingPhoneNumber in phoneNumbers) {
|
||||
CNPhoneNumber *phoneNumber = existingPhoneNumber.value;
|
||||
if ([phoneNumber.stringValue isEqualToString:recipientId]) {
|
||||
OWSFail(@"We currently only should the 'add to existing contact' UI for phone numbers that don't "
|
||||
@"correspond to an existing user.");
|
||||
hasPhoneNumber = YES;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,21 +12,6 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NamedContact : NSObject
|
||||
|
||||
@property (nonatomic) Contact *contact;
|
||||
@property (nonatomic) NSString *displayName;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation NamedContact
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSAddToContactViewController () <ContactEditingDelegate, ContactsViewHelperDelegate>
|
||||
|
||||
@property (nonatomic) NSString *recipientId;
|
||||
|
@ -175,7 +160,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
section.headerTitle = NSLocalizedString(
|
||||
@"EDIT_GROUP_CONTACTS_SECTION_TITLE", @"a title for the contacts section of the 'new/update group' view.");
|
||||
|
||||
NSMutableArray<NamedContact *> *namedContacts = [NSMutableArray new];
|
||||
for (Contact *contact in self.contactsViewHelper.contactsManager.allContacts) {
|
||||
OWSAssert(contact.cnContact);
|
||||
|
||||
|
@ -184,21 +168,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
continue;
|
||||
}
|
||||
|
||||
NamedContact *namedContact = [NamedContact new];
|
||||
namedContact.contact = contact;
|
||||
namedContact.displayName = displayName;
|
||||
[namedContacts addObject:namedContact];
|
||||
}
|
||||
|
||||
[namedContacts sortUsingComparator:^NSComparisonResult(NamedContact *_Nonnull left, NamedContact *_Nonnull right) {
|
||||
return [left.displayName caseInsensitiveCompare:right.displayName];
|
||||
}];
|
||||
|
||||
for (NamedContact *namedContact in namedContacts) {
|
||||
[section addItem:[OWSTableItem disclosureItemWithText:namedContact.displayName
|
||||
[section addItem:[OWSTableItem disclosureItemWithText:displayName
|
||||
actionBlock:^{
|
||||
[weakSelf
|
||||
presentContactViewControllerForContact:namedContact.contact];
|
||||
[weakSelf presentContactViewControllerForContact:contact];
|
||||
}]];
|
||||
}
|
||||
[contents addSection:section];
|
||||
|
|
|
@ -167,7 +167,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSContactThread *contactThread = (TSContactThread *)self.thread;
|
||||
NSString *recipientId = contactThread.contactIdentifier;
|
||||
SignalAccount *signalAccount = [self.contactsViewHelper signalAccountForRecipientId:recipientId];
|
||||
return signalAccount.contact;
|
||||
return signalAccount.contact != nil;
|
||||
}
|
||||
|
||||
#pragma mark - ContactEditingDelegate
|
||||
|
|
|
@ -157,6 +157,8 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|||
[self intersectContacts];
|
||||
|
||||
[self updateSignalAccounts];
|
||||
|
||||
[self updateCachedDisplayNames];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -203,10 +205,6 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|||
self.signalAccounts = [signalAccounts copy];
|
||||
|
||||
[self updateCachedDisplayNames];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:OWSContactsManagerSignalAccountsDidChangeNotification
|
||||
object:nil];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -238,6 +236,20 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|||
}
|
||||
}
|
||||
|
||||
// As a fallback, make sure we can also display names for not-yet-registered
|
||||
// and no-longer-registered users.
|
||||
for (Contact *contact in self.allContacts) {
|
||||
NSString *displayName = contact.fullName;
|
||||
if (displayName.length > 0) {
|
||||
for (PhoneNumber *phoneNumber in contact.parsedPhoneNumbers) {
|
||||
NSString *e164 = phoneNumber.toE164;
|
||||
if (!cachedAccountNameMap[e164]) {
|
||||
cachedAccountNameMap[e164] = displayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.cachedAccountNameMap = [cachedAccountNameMap copy];
|
||||
self.cachedFirstNameMap = [cachedFirstNameMap copy];
|
||||
self.cachedLastNameMap = [cachedLastNameMap copy];
|
||||
|
@ -262,6 +274,9 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|||
}
|
||||
}];
|
||||
});
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:OWSContactsManagerSignalAccountsDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)loadCachedDisplayNames
|
||||
|
|
|
@ -332,7 +332,7 @@
|
|||
"CONVERSATION_SETTINGS_MUTED_UNTIL_FORMAT" = "until %@";
|
||||
|
||||
/* Label for 'new contact' button in conversation settings view. */
|
||||
"CONVERSATION_SETTINGS_NEW_CONTACT" = "New Contact";
|
||||
"CONVERSATION_SETTINGS_NEW_CONTACT" = "Create New Contact";
|
||||
|
||||
/* Label for button to unmute a thread. */
|
||||
"CONVERSATION_SETTINGS_UNMUTE_ACTION" = "Unmute";
|
||||
|
|
Loading…
Reference in New Issue