diff --git a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m index e54d794c9..733f00176 100644 --- a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m +++ b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m @@ -14,6 +14,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -57,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN __weak BlockListViewController *weakSelf = self; ContactsViewHelper *helper = self.contactsViewHelper; - // Add section + // "Add" section OWSTableSection *addSection = [OWSTableSection new]; addSection.footerTitle = NSLocalizedString( @@ -73,29 +74,61 @@ NS_ASSUME_NONNULL_BEGIN }]]; [contents addSection:addSection]; - // Blocklist section + // "Blocklist" section - OWSTableSection *blocklistSection = [OWSTableSection new]; NSArray *blockedPhoneNumbers = [helper.blockedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)]; - for (NSString *phoneNumber in blockedPhoneNumbers) { - [blocklistSection addItem:[OWSTableItem - itemWithCustomCellBlock:^{ - ContactTableViewCell *cell = [ContactTableViewCell new]; - [cell configureWithRecipientId:phoneNumber - contactsManager:helper.contactsManager]; - return cell; - } - customRowHeight:UITableViewAutomaticDimension - actionBlock:^{ - [BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber - fromViewController:weakSelf - blockingManager:helper.blockingManager - contactsManager:helper.contactsManager - completionBlock:nil]; - }]]; + + if (blockedPhoneNumbers.count > 0) { + OWSTableSection *blockedContactsSection = [OWSTableSection new]; + blockedContactsSection.headerTitle + = NSLocalizedString(@"BLOCK_LIST_BLOCKED_USERS_SECTION", @"Section header for users that has been blocked"); + + for (NSString *phoneNumber in blockedPhoneNumbers) { + [blockedContactsSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + ContactTableViewCell *cell = [ContactTableViewCell new]; + [cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; + return cell; + } + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + [BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber + fromViewController:weakSelf + blockingManager:helper.blockingManager + contactsManager:helper.contactsManager + completionBlock:nil]; + }]]; + } + [contents addSection:blockedContactsSection]; + } + + NSArray *blockedGroupIds = helper.blockedGroupIds; + if (blockedGroupIds.count > 0) { + OWSTableSection *blockedGroupsSection = [OWSTableSection new]; + blockedGroupsSection.headerTitle = NSLocalizedString( + @"BLOCK_LIST_BLOCKED_GROUPS_SECTION", @"Section header for groups that has been blocked"); + for (NSData *groupId in blockedGroupIds) { + TSGroupThread *groupThread = [TSGroupThread getOrCreateThreadWithGroupId:groupId]; + [blockedGroupsSection addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + ContactTableViewCell *cell = [ContactTableViewCell new]; + [cell configureWithThread:groupThread + contactsManager:helper.contactsManager]; + return cell; + } + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + [BlockListUIUtils showUnblockThreadActionSheet:groupThread + fromViewController:weakSelf + blockingManager:helper.blockingManager + contactsManager:helper.contactsManager + completionBlock:nil]; + }]]; + } + [contents addSection:blockedGroupsSection]; } - [contents addSection:blocklistSection]; self.tableViewController.contents = contents; } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index b4492e5bd..b023863dc 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -236,6 +236,12 @@ /* A format for the 'block user' action sheet title. Embeds {{the blocked user's name or phone number}}. */ "BLOCK_LIST_BLOCK_USER_TITLE_FORMAT" = "Block %@?"; +/* Section header for groups that has been blocked */ +"BLOCK_LIST_BLOCKED_GROUPS_SECTION" = "Blocked Groups"; + +/* Section header for users that has been blocked */ +"BLOCK_LIST_BLOCKED_USERS_SECTION" = "Blocked Users"; + /* Button label for the 'unblock' button */ "BLOCK_LIST_UNBLOCK_BUTTON" = "Unblock"; @@ -251,12 +257,6 @@ /* A label for the block button in the block list view */ "BLOCK_LIST_VIEW_BLOCK_BUTTON" = "Block"; -/* The title of the 'block user failed' alert. */ -"BLOCK_LIST_VIEW_BLOCK_FAILED_ALERT_MESSAGE" = "Failed to Block User."; - -/* The title of the 'block user failed' alert. */ -"BLOCK_LIST_VIEW_BLOCK_FAILED_ALERT_TITLE" = "Error"; - /* The message format of the 'conversation blocked' alert. Embeds the {{conversation title}}. */ "BLOCK_LIST_VIEW_BLOCKED_ALERT_MESSAGE_FORMAT" = "%@ has been blocked"; @@ -272,12 +272,6 @@ /* The title of the 'You can't block yourself' alert. */ "BLOCK_LIST_VIEW_CANT_BLOCK_SELF_ALERT_TITLE" = "Error"; -/* The title of the 'unblock user failed' alert. */ -"BLOCK_LIST_VIEW_UNBLOCK_FAILED_ALERT_MESSAGE" = "Failed to Unblock User."; - -/* The title of the 'unblock user failed' alert. */ -"BLOCK_LIST_VIEW_UNBLOCK_FAILED_ALERT_TITLE" = "Error"; - /* Alert body after unblocking a group or 1:1 chat. Embeds the conversation title. */ "BLOCK_LIST_VIEW_UNBLOCKED_ALERT_MESSAGE_FORMAT" = "%@ has been unblocked."; @@ -1950,7 +1944,7 @@ "SETTINGS_BACKUP_STATUS_SUCCEEDED" = "Backup Successful"; /* A label for the 'add phone number' button in the block list table. */ -"SETTINGS_BLOCK_LIST_ADD_BUTTON" = "Add…"; +"SETTINGS_BLOCK_LIST_ADD_BUTTON" = "Add Blocked User"; /* A label that indicates the user has no Signal contacts. */ "SETTINGS_BLOCK_LIST_NO_CONTACTS" = "You have no contacts on Signal."; diff --git a/SignalMessaging/Views/ContactsViewHelper.h b/SignalMessaging/Views/ContactsViewHelper.h index 29306575e..deabf7a14 100644 --- a/SignalMessaging/Views/ContactsViewHelper.h +++ b/SignalMessaging/Views/ContactsViewHelper.h @@ -48,6 +48,7 @@ NS_ASSUME_NONNULL_BEGIN // MJK TODO Can we remove? Do we need blockedGroupList? @property (nonatomic, readonly) NSArray *blockedPhoneNumbers; +@property (nonatomic, readonly) NSArray *blockedGroupIds; // Suitable when the user tries to perform an action which is not possible due to the user having // previously denied contact access.