Merge branch 'charlesmchen/cantBlockSelf'

pull/1/head
Matthew Chen 7 years ago
commit a15e8b2d9b

@ -7,6 +7,7 @@
#import "PhoneNumber.h"
#import <SignalServiceKit/Contact.h>
#import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/TSAccountManager.h>
NS_ASSUME_NONNULL_BEGIN
@ -72,6 +73,26 @@ typedef void (^BlockAlertCompletionBlock)();
OWSAssert(fromViewController);
OWSAssert(blockingManager);
NSString *localContactId = [TSAccountManager localNumber];
OWSAssert(localContactId.length > 0);
for (NSString *phoneNumber in phoneNumbers) {
OWSAssert(phoneNumber.length > 0);
if ([localContactId isEqualToString:phoneNumber]) {
[self showOkAlertWithTitle:NSLocalizedString(@"BLOCK_LIST_VIEW_CANT_BLOCK_SELF_ALERT_TITLE",
@"The title of the 'You can't block yourself' alert.")
message:NSLocalizedString(@"BLOCK_LIST_VIEW_CANT_BLOCK_SELF_ALERT_MESSAGE",
@"The title of the 'You can't block yourself' alert.")
fromViewController:fromViewController
completionBlock:^{
if (completionBlock) {
completionBlock(NO);
}
}];
return;
}
}
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_BLOCK_TITLE_FORMAT",
@"A format for the 'block user' action sheet title. Embeds {{the "
@"blocked user's name or phone number}}."),

@ -130,6 +130,12 @@
/* The title of the 'user blocked' alert. */
"BLOCK_LIST_VIEW_BLOCKED_ALERT_TITLE" = "User Blocked";
/* The title of the 'You can't block yourself' alert. */
"BLOCK_LIST_VIEW_CANT_BLOCK_SELF_ALERT_MESSAGE" = "You can't block yourself.";
/* The title of the 'You can't block yourself' alert. */
"BLOCK_LIST_VIEW_CANT_BLOCK_SELF_ALERT_TITLE" = "Error";
/* A title for the contacts section of the block list view. */
"BLOCK_LIST_VIEW_CONTACTS_SECTION_TITLE" = "Contacts";

Loading…
Cancel
Save