From 2eca462efce9a372de7020d2adcf8fab1545a5fe Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 10 Sep 2018 18:48:37 -0500 Subject: [PATCH] can view conversation settings for left group --- .../ConversationViewController.m | 35 +++---- .../OWSConversationSettingsViewController.m | 95 +++++++++++++------ 2 files changed, 77 insertions(+), 53 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 2ffb0f3e8..07c8ee279 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1417,25 +1417,17 @@ typedef enum : NSUInteger { }]]; } - if (self.userLeftGroup) { - [subtitleText - appendAttributedString:[[NSAttributedString alloc] - initWithString:NSLocalizedString(@"GROUP_YOU_LEFT", @"") - attributes:@{ - NSFontAttributeName : self.headerView.subtitleFont, - NSForegroundColorAttributeName : subtitleColor, - }]]; - } else { - [subtitleText appendAttributedString: - [[NSAttributedString alloc] - initWithString:NSLocalizedString(@"MESSAGES_VIEW_TITLE_SUBTITLE", - @"The subtitle for the messages view title indicates that the " - @"title can be tapped to access settings for this conversation.") - attributes:@{ - NSFontAttributeName : self.headerView.subtitleFont, - NSForegroundColorAttributeName : subtitleColor, - }]]; - } + + [subtitleText + appendAttributedString:[[NSAttributedString alloc] + initWithString:NSLocalizedString(@"MESSAGES_VIEW_TITLE_SUBTITLE", + @"The subtitle for the messages view title indicates that the " + @"title can be tapped to access settings for this conversation.") + attributes:@{ + NSFontAttributeName : self.headerView.subtitleFont, + NSForegroundColorAttributeName : subtitleColor, + }]]; + self.headerView.attributedSubtitle = subtitleText; } @@ -1577,11 +1569,6 @@ typedef enum : NSUInteger { - (void)showConversationSettingsAndShowVerification:(BOOL)showVerification { - if (self.userLeftGroup) { - DDLogDebug(@"%@ Ignoring request to show conversation settings, since user left group", self.logTag); - return; - } - OWSConversationSettingsViewController *settingsVC = [OWSConversationSettingsViewController new]; settingsVC.conversationSettingsViewDelegate = self; [settingsVC configureWithThread:self.thread uiDatabaseConnection:self.uiDatabaseConnection]; diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 315814dd1..bcbffca84 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -351,20 +351,24 @@ const CGFloat kIconViewLength = 24; } actionBlock:nil]]; } else { - [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return - [weakSelf disclosureCellWithName:(self.isGroupThread - ? NSLocalizedString( - @"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP", - @"Action that shares user profile with a group.") - : NSLocalizedString( - @"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER", - @"Action that shares user profile with a user."))iconName - :@"table_ic_share_profile"]; - } - actionBlock:^{ - [weakSelf showShareProfileAlert]; - }]]; + [mainSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = [weakSelf + disclosureCellWithName: + (self.isGroupThread + ? NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP", + @"Action that shares user profile with a group.") + : NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER", + @"Action that shares user profile with a user.")) + iconName:@"table_ic_share_profile"]; + cell.userInteractionEnabled = !weakSelf.hasLeftGroup; + + return cell; + } + actionBlock:^{ + [weakSelf showShareProfileAlert]; + }]]; } [mainSection addItem:[OWSTableItem @@ -414,6 +418,8 @@ const CGFloat kIconViewLength = 24; [subtitleLabel autoPinTrailingToSuperviewMargin]; [subtitleLabel autoPinBottomToSuperviewMargin]; + cell.userInteractionEnabled = !strongSelf.hasLeftGroup; + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -460,6 +466,8 @@ const CGFloat kIconViewLength = 24; [slider autoPinTrailingToSuperviewMargin]; [slider autoPinBottomToSuperviewMargin]; + cell.userInteractionEnabled = !strongSelf.hasLeftGroup; + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -472,27 +480,40 @@ const CGFloat kIconViewLength = 24; if (self.isGroupThread) { NSArray *groupItems = @[ - [OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf disclosureCellWithName:NSLocalizedString(@"EDIT_GROUP_ACTION", - @"table cell label in conversation settings") - iconName:@"table_ic_group_edit"]; - } + [OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = + [weakSelf disclosureCellWithName:NSLocalizedString(@"EDIT_GROUP_ACTION", + @"table cell label in conversation settings") + iconName:@"table_ic_group_edit"]; + cell.userInteractionEnabled = !weakSelf.hasLeftGroup; + return cell; + } actionBlock:^{ [weakSelf showUpdateGroupView:UpdateGroupMode_Default]; }], - [OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf disclosureCellWithName:NSLocalizedString(@"LIST_GROUP_MEMBERS_ACTION", - @"table cell label in conversation settings") - iconName:@"table_ic_group_members"]; - } + [OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = + [weakSelf disclosureCellWithName:NSLocalizedString(@"LIST_GROUP_MEMBERS_ACTION", + @"table cell label in conversation settings") + iconName:@"table_ic_group_members"]; + cell.userInteractionEnabled = !weakSelf.hasLeftGroup; + return cell; + } actionBlock:^{ [weakSelf showGroupMembersView]; }], - [OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", - @"table cell label in conversation settings") - iconName:@"table_ic_group_leave"]; - } + [OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = + [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", + @"table cell label in conversation settings") + iconName:@"table_ic_group_leave"]; + cell.userInteractionEnabled = !weakSelf.hasLeftGroup; + + return cell; + } actionBlock:^{ [weakSelf didTapLeaveGroup]; }], @@ -827,6 +848,11 @@ const CGFloat kIconViewLength = 24; - (void)conversationNameTouched:(UIGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateRecognized) { + if (self.hasLeftGroup) { + DDLogVerbose(@"%@ ignoring tap for left group thread.", self.logTag); + return; + } + if (self.isGroupThread) { CGPoint location = [sender locationInView:self.avatarView]; if (CGRectContainsPoint(self.avatarView.bounds, location)) { @@ -996,6 +1022,17 @@ const CGFloat kIconViewLength = 24; [self presentViewController:alertController animated:YES completion:nil]; } +- (BOOL)hasLeftGroup +{ + if (self.isGroupThread) { + TSGroupThread *groupThread = (TSGroupThread *)self.thread; + BOOL inGroup = [groupThread.groupModel.groupMemberIds containsObject:TSAccountManager.localNumber]; + return !inGroup; + } + + return NO; +} + - (void)leaveGroup { TSGroupThread *gThread = (TSGroupThread *)self.thread;