From cb9d96be0007a359e29758c3eade69d3dfff1722 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 28 Apr 2017 14:58:55 -0400 Subject: [PATCH] Clean up ahead of PR. // FREEBIE --- Signal/src/ViewControllers/ContactAccount.h | 7 ------- Signal/src/ViewControllers/ContactsViewHelper.m | 6 +----- Signal/src/ViewControllers/GroupViewHelper.m | 2 +- .../src/ViewControllers/SelectRecipientViewController.m | 8 ++++++-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Signal/src/ViewControllers/ContactAccount.h b/Signal/src/ViewControllers/ContactAccount.h index 94881e656..307f8f654 100644 --- a/Signal/src/ViewControllers/ContactAccount.h +++ b/Signal/src/ViewControllers/ContactAccount.h @@ -16,13 +16,6 @@ NS_ASSUME_NONNULL_BEGIN // An E164 value identifying the signal account. @property (nonatomic) NSString *recipientId; -//// TODO: -//@property (nonatomic) NSString *displayName; -// -//// TODO: -//@property (nonatomic) NSAttributedString *attributedDisplayName; - -// TODO: This might be redundant. @property (nonatomic) BOOL isMultipleAccountContact; // For contacts with more than one signal account, diff --git a/Signal/src/ViewControllers/ContactsViewHelper.m b/Signal/src/ViewControllers/ContactsViewHelper.m index f0dc336cf..497004d24 100644 --- a/Signal/src/ViewControllers/ContactsViewHelper.m +++ b/Signal/src/ViewControllers/ContactsViewHelper.m @@ -107,9 +107,6 @@ NS_ASSUME_NONNULL_BEGIN if (contact.textSecureIdentifiers.count == 1) { ContactAccount *contactAccount = [ContactAccount new]; contactAccount.contact = contact; - // contactAccount.displayName = contact.fullName; - // contactAccount.attributedDisplayName = [self.contactsManager - // formattedFullNameForContact:contact]; NSString *recipientId = contact.textSecureIdentifiers[0]; contactAccount.recipientId = recipientId; [allRecipientContactAccounts addObject:contactAccount]; @@ -121,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN contactAccount.contact = contact; contactAccount.recipientId = recipientId; contactAccount.isMultipleAccountContact = YES; - // TODO: + // TODO: Store the phone number's "label" if possible. contactAccount.multipleAccountLabel = recipientId; [allRecipientContactAccounts addObject:contactAccount]; contactAccountMap[recipientId] = contactAccount; @@ -240,7 +237,6 @@ NS_ASSUME_NONNULL_BEGIN - (NSArray *)contactAccountsMatchingSearchString:(NSString *)searchText { - NSArray *searchTerms = [[searchText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; diff --git a/Signal/src/ViewControllers/GroupViewHelper.m b/Signal/src/ViewControllers/GroupViewHelper.m index 4049bbceb..84b7fedcc 100644 --- a/Signal/src/ViewControllers/GroupViewHelper.m +++ b/Signal/src/ViewControllers/GroupViewHelper.m @@ -191,7 +191,7 @@ NS_ASSUME_NONNULL_BEGIN UIImage *rawAvatar = [info objectForKey:UIImagePickerControllerOriginalImage]; if (rawAvatar) { - // TODO: This is busted. + // TODO: There may be a bug here. UIImage *resizedAvatar = [rawAvatar resizedImageToFitInSize:CGSizeMake(100.00, 100.00) scaleIfSmaller:NO]; [self.delegate groupAvatarDidChange:resizedAvatar]; } diff --git a/Signal/src/ViewControllers/SelectRecipientViewController.m b/Signal/src/ViewControllers/SelectRecipientViewController.m index e04e8cef0..01f50ed21 100644 --- a/Signal/src/ViewControllers/SelectRecipientViewController.m +++ b/Signal/src/ViewControllers/SelectRecipientViewController.m @@ -248,9 +248,11 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien return; } + NSString *rawPhoneNumber = [self.callingCode stringByAppendingString:self.phoneNumberTextField.text.digitsOnly]; + NSMutableArray *possiblePhoneNumbers = [NSMutableArray new]; for (PhoneNumber *phoneNumber in - [PhoneNumber tryParsePhoneNumbersFromsUserSpecifiedText:self.phoneNumberTextField.text.digitsOnly + [PhoneNumber tryParsePhoneNumbersFromsUserSpecifiedText:rawPhoneNumber clientPhoneNumber:[TSStorageManager localNumber]]) { [possiblePhoneNumbers addObject:phoneNumber.toE164]; } @@ -258,6 +260,9 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien OWSAssert(0); return; } + // There should only be one phone number, since we're explicitly specifying + // a country code and therefore parsing a number in e164 format. + OWSAssert([possiblePhoneNumbers count] == 1); if ([self.delegate shouldValidatePhoneNumbers]) { // Show an alert while validating the recipient. @@ -305,7 +310,6 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien }]; }]; } else { - // Use just the first phone number. NSString *recipientId = possiblePhoneNumbers[0]; [self.delegate phoneNumberWasSelected:recipientId]; }