group blocking v. conversation view

pull/1/head
Michael Kirk 7 years ago
parent eadb04efcc
commit b1da5e93d9

@ -865,10 +865,14 @@ typedef enum : NSUInteger {
} }
NSString *blockStateMessage = nil; NSString *blockStateMessage = nil;
// FIXME - group blocking if ([self isBlockedConversation]) {
if ([self isBlockedContactConversation]) { if (self.isGroupConversation) {
blockStateMessage = NSLocalizedString( blockStateMessage = NSLocalizedString(
@"MESSAGES_VIEW_CONTACT_BLOCKED", @"Indicates that this 1:1 conversation has been blocked."); @"MESSAGES_VIEW_GROUP_BLOCKED", @"Indicates that this group conversation has been blocked.");
} else {
blockStateMessage = NSLocalizedString(
@"MESSAGES_VIEW_CONTACT_BLOCKED", @"Indicates that this 1:1 conversation has been blocked.");
}
} else if (self.isGroupConversation) { } else if (self.isGroupConversation) {
int blockedGroupMemberCount = [self blockedGroupMemberCount]; int blockedGroupMemberCount = [self blockedGroupMemberCount];
if (blockedGroupMemberCount == 1) { if (blockedGroupMemberCount == 1) {
@ -965,9 +969,9 @@ typedef enum : NSUInteger {
return; return;
} }
if ([self isBlockedContactConversation]) { if ([self isBlockedConversation]) {
// If this a blocked 1:1 conversation, offer to unblock the user. // If this a blocked conversation, offer to unblock.
[self showUnblockContactUI:nil]; [self showUnblockConversationUI:nil];
} else if (self.isGroupConversation) { } else if (self.isGroupConversation) {
// If this a group conversation with at least one blocked member, // If this a group conversation with at least one blocked member,
// Show the block list view. // Show the block list view.
@ -1055,10 +1059,8 @@ typedef enum : NSUInteger {
} }
} }
- (void)showUnblockContactUI:(nullable BlockActionCompletionBlock)completionBlock - (void)showUnblockConversationUI:(nullable BlockActionCompletionBlock)completionBlock
{ {
OWSAssert([self.thread isKindOfClass:[TSContactThread class]]);
self.userHasScrolled = NO; self.userHasScrolled = NO;
// To avoid "noisy" animations (hiding the keyboard before showing // To avoid "noisy" animations (hiding the keyboard before showing
@ -1069,21 +1071,16 @@ typedef enum : NSUInteger {
// hidden. // hidden.
[self dismissKeyBoard]; [self dismissKeyBoard];
NSString *contactIdentifier = ((TSContactThread *)self.thread).contactIdentifier; [BlockListUIUtils showUnblockThreadActionSheet:self.thread
[BlockListUIUtils showUnblockPhoneNumberActionSheet:contactIdentifier fromViewController:self
fromViewController:self blockingManager:self.blockingManager
blockingManager:_blockingManager contactsManager:self.contactsManager
contactsManager:_contactsManager completionBlock:completionBlock];
completionBlock:completionBlock];
} }
- (BOOL)isBlockedContactConversation - (BOOL)isBlockedConversation
{ {
if (![self.thread isKindOfClass:[TSContactThread class]]) { return [self.blockingManager isThreadBlocked:self.thread];
return NO;
}
NSString *contactIdentifier = ((TSContactThread *)self.thread).contactIdentifier;
return [[_blockingManager blockedPhoneNumbers] containsObject:contactIdentifier];
} }
- (int)blockedGroupMemberCount - (int)blockedGroupMemberCount
@ -1511,8 +1508,8 @@ typedef enum : NSUInteger {
} }
__weak ConversationViewController *weakSelf = self; __weak ConversationViewController *weakSelf = self;
if ([self isBlockedContactConversation]) { if ([self isBlockedConversation]) {
[self showUnblockContactUI:^(BOOL isBlocked) { [self showUnblockConversationUI:^(BOOL isBlocked) {
if (!isBlocked) { if (!isBlocked) {
[weakSelf callWithVideo:isVideo]; [weakSelf callWithVideo:isVideo];
} }
@ -3740,8 +3737,8 @@ typedef enum : NSUInteger {
[self dismissKeyBoard]; [self dismissKeyBoard];
__weak ConversationViewController *weakSelf = self; __weak ConversationViewController *weakSelf = self;
if ([self isBlockedContactConversation]) { if ([self isBlockedConversation]) {
[self showUnblockContactUI:^(BOOL isBlocked) { [self showUnblockConversationUI:^(BOOL isBlocked) {
if (!isBlocked) { if (!isBlocked) {
[weakSelf attachmentButtonPressed]; [weakSelf attachmentButtonPressed];
} }
@ -4097,8 +4094,8 @@ typedef enum : NSUInteger {
DispatchMainThreadSafe(^{ DispatchMainThreadSafe(^{
__weak ConversationViewController *weakSelf = self; __weak ConversationViewController *weakSelf = self;
if ([self isBlockedContactConversation]) { if ([self isBlockedConversation]) {
[self showUnblockContactUI:^(BOOL isBlocked) { [self showUnblockConversationUI:^(BOOL isBlocked) {
if (!isBlocked) { if (!isBlocked) {
[weakSelf tryToSendAttachmentIfApproved:attachment]; [weakSelf tryToSendAttachmentIfApproved:attachment];
} }
@ -4407,8 +4404,8 @@ typedef enum : NSUInteger {
{ {
__weak ConversationViewController *weakSelf = self; __weak ConversationViewController *weakSelf = self;
if ([self isBlockedContactConversation]) { if ([self isBlockedConversation]) {
[self showUnblockContactUI:^(BOOL isBlocked) { [self showUnblockConversationUI:^(BOOL isBlocked) {
if (!isBlocked) { if (!isBlocked) {
[weakSelf tryToSendTextMessage:text updateKeyboardState:NO]; [weakSelf tryToSendTextMessage:text updateKeyboardState:NO];
} }

Loading…
Cancel
Save