Merge branch 'charlesmchen/blockedUsersVsNewGroups'

This commit is contained in:
Matthew Chen 2017-05-12 09:27:09 -04:00
commit 9f2414b371
3 changed files with 65 additions and 33 deletions

View file

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

View file

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

View file

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