Don’t add blocked users to new groups and handle block alert results correctly.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 5a69917cfd
commit 0ff3e5e6a3

@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
blockingManager:helper.blockingManager blockingManager:helper.blockingManager
contactsManager:helper.contactsManager contactsManager:helper.contactsManager
completionBlock:^(BOOL isBlocked) { completionBlock:^(BOOL isBlocked) {
if (isBlocked) { if (!isBlocked) {
[weakSelf addToGroup:phoneNumber]; [weakSelf addToGroup:phoneNumber];
} }
}]; }];
@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
blockingManager:helper.blockingManager blockingManager:helper.blockingManager
contactsManager:helper.contactsManager contactsManager:helper.contactsManager
completionBlock:^(BOOL isBlocked) { completionBlock:^(BOOL isBlocked) {
if (isBlocked) { if (!isBlocked) {
[weakSelf addToGroup:signalAccount.recipientId]; [weakSelf addToGroup:signalAccount.recipientId];
} }
}]; }];

@ -4,6 +4,7 @@
#import "NewGroupViewController.h" #import "NewGroupViewController.h"
#import "AddToGroupViewController.h" #import "AddToGroupViewController.h"
#import "BlockListUIUtils.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
@ -205,7 +206,8 @@ NS_ASSUME_NONNULL_BEGIN
for (NSString *recipientId in for (NSString *recipientId in
[nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) { [nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[nonContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [nonContactsSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf; NewGroupViewController *strongSelf = weakSelf;
OWSAssert(strongSelf); OWSAssert(strongSelf);
@ -225,7 +227,8 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager];
} else { } else {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager]; [cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager];
} }
@ -234,7 +237,24 @@ NS_ASSUME_NONNULL_BEGIN
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{ actionBlock:^{
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isCurrentMember) {
[weakSelf removeRecipientId:recipientId]; [weakSelf removeRecipientId:recipientId];
} else if (isBlocked) {
[BlockListUIUtils
showUnblockPhoneNumberActionSheet:recipientId
fromViewController:weakSelf
blockingManager:contactsViewHelper.blockingManager
contactsManager:contactsViewHelper.contactsManager
completionBlock:^(BOOL isStillBlocked) {
if (!isStillBlocked) {
[weakSelf addRecipientId:recipientId];
}
}];
} else {
[weakSelf addRecipientId:recipientId];
}
}]]; }]];
} }
[contents addSection:nonContactsSection]; [contents addSection:nonContactsSection];
@ -287,8 +307,20 @@ NS_ASSUME_NONNULL_BEGIN
actionBlock:^{ actionBlock:^{
NSString *recipientId = signalAccount.recipientId; NSString *recipientId = signalAccount.recipientId;
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isCurrentMember) { if (isCurrentMember) {
[weakSelf removeRecipientId:recipientId]; [weakSelf removeRecipientId:recipientId];
} else if (isBlocked) {
[BlockListUIUtils
showUnblockSignalAccountActionSheet:signalAccount
fromViewController:weakSelf
blockingManager:contactsViewHelper.blockingManager
contactsManager:contactsViewHelper.contactsManager
completionBlock:^(BOOL isStillBlocked) {
if (!isStillBlocked) {
[weakSelf addRecipientId:recipientId];
}
}];
} else { } else {
[weakSelf addRecipientId:recipientId]; [weakSelf addRecipientId:recipientId];
} }

@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN
blockingManager:helper.blockingManager blockingManager:helper.blockingManager
contactsManager:helper.contactsManager contactsManager:helper.contactsManager
completionBlock:^(BOOL isBlocked) { completionBlock:^(BOOL isBlocked) {
if (isBlocked) { if (!isBlocked) {
[weakSelf selectRecipient:phoneNumber]; [weakSelf selectRecipient:phoneNumber];
} }
}]; }];
@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
blockingManager:helper.blockingManager blockingManager:helper.blockingManager
contactsManager:helper.contactsManager contactsManager:helper.contactsManager
completionBlock:^(BOOL isBlocked) { completionBlock:^(BOOL isBlocked) {
if (isBlocked) { if (!isBlocked) {
[weakSelf selectRecipient:signalAccount.recipientId]; [weakSelf selectRecipient:signalAccount.recipientId];
} }
}]; }];

Loading…
Cancel
Save