can view conversation settings for left group

pull/1/head
Michael Kirk 7 years ago
parent 2c49232db0
commit 2eca462efc

@ -1417,17 +1417,9 @@ typedef enum : NSUInteger {
}]]; }]];
} }
if (self.userLeftGroup) {
[subtitleText [subtitleText
appendAttributedString:[[NSAttributedString alloc] 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", initWithString:NSLocalizedString(@"MESSAGES_VIEW_TITLE_SUBTITLE",
@"The subtitle for the messages view title indicates that the " @"The subtitle for the messages view title indicates that the "
@"title can be tapped to access settings for this conversation.") @"title can be tapped to access settings for this conversation.")
@ -1435,7 +1427,7 @@ typedef enum : NSUInteger {
NSFontAttributeName : self.headerView.subtitleFont, NSFontAttributeName : self.headerView.subtitleFont,
NSForegroundColorAttributeName : subtitleColor, NSForegroundColorAttributeName : subtitleColor,
}]]; }]];
}
self.headerView.attributedSubtitle = subtitleText; self.headerView.attributedSubtitle = subtitleText;
} }
@ -1577,11 +1569,6 @@ typedef enum : NSUInteger {
- (void)showConversationSettingsAndShowVerification:(BOOL)showVerification - (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]; OWSConversationSettingsViewController *settingsVC = [OWSConversationSettingsViewController new];
settingsVC.conversationSettingsViewDelegate = self; settingsVC.conversationSettingsViewDelegate = self;
[settingsVC configureWithThread:self.thread uiDatabaseConnection:self.uiDatabaseConnection]; [settingsVC configureWithThread:self.thread uiDatabaseConnection:self.uiDatabaseConnection];

@ -351,16 +351,20 @@ const CGFloat kIconViewLength = 24;
} }
actionBlock:nil]]; actionBlock:nil]];
} else { } else {
[mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [mainSection
return addItem:[OWSTableItem
[weakSelf disclosureCellWithName:(self.isGroupThread itemWithCustomCellBlock:^{
? NSLocalizedString( UITableViewCell *cell = [weakSelf
@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP", disclosureCellWithName:
(self.isGroupThread
? NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP",
@"Action that shares user profile with a group.") @"Action that shares user profile with a group.")
: NSLocalizedString( : NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER",
@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER", @"Action that shares user profile with a user."))
@"Action that shares user profile with a user."))iconName iconName:@"table_ic_share_profile"];
:@"table_ic_share_profile"]; cell.userInteractionEnabled = !weakSelf.hasLeftGroup;
return cell;
} }
actionBlock:^{ actionBlock:^{
[weakSelf showShareProfileAlert]; [weakSelf showShareProfileAlert];
@ -414,6 +418,8 @@ const CGFloat kIconViewLength = 24;
[subtitleLabel autoPinTrailingToSuperviewMargin]; [subtitleLabel autoPinTrailingToSuperviewMargin];
[subtitleLabel autoPinBottomToSuperviewMargin]; [subtitleLabel autoPinBottomToSuperviewMargin];
cell.userInteractionEnabled = !strongSelf.hasLeftGroup;
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
@ -460,6 +466,8 @@ const CGFloat kIconViewLength = 24;
[slider autoPinTrailingToSuperviewMargin]; [slider autoPinTrailingToSuperviewMargin];
[slider autoPinBottomToSuperviewMargin]; [slider autoPinBottomToSuperviewMargin];
cell.userInteractionEnabled = !strongSelf.hasLeftGroup;
return cell; return cell;
} }
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
@ -472,26 +480,39 @@ const CGFloat kIconViewLength = 24;
if (self.isGroupThread) { if (self.isGroupThread) {
NSArray *groupItems = @[ NSArray *groupItems = @[
[OWSTableItem itemWithCustomCellBlock:^{ [OWSTableItem
return [weakSelf disclosureCellWithName:NSLocalizedString(@"EDIT_GROUP_ACTION", itemWithCustomCellBlock:^{
UITableViewCell *cell =
[weakSelf disclosureCellWithName:NSLocalizedString(@"EDIT_GROUP_ACTION",
@"table cell label in conversation settings") @"table cell label in conversation settings")
iconName:@"table_ic_group_edit"]; iconName:@"table_ic_group_edit"];
cell.userInteractionEnabled = !weakSelf.hasLeftGroup;
return cell;
} }
actionBlock:^{ actionBlock:^{
[weakSelf showUpdateGroupView:UpdateGroupMode_Default]; [weakSelf showUpdateGroupView:UpdateGroupMode_Default];
}], }],
[OWSTableItem itemWithCustomCellBlock:^{ [OWSTableItem
return [weakSelf disclosureCellWithName:NSLocalizedString(@"LIST_GROUP_MEMBERS_ACTION", itemWithCustomCellBlock:^{
UITableViewCell *cell =
[weakSelf disclosureCellWithName:NSLocalizedString(@"LIST_GROUP_MEMBERS_ACTION",
@"table cell label in conversation settings") @"table cell label in conversation settings")
iconName:@"table_ic_group_members"]; iconName:@"table_ic_group_members"];
cell.userInteractionEnabled = !weakSelf.hasLeftGroup;
return cell;
} }
actionBlock:^{ actionBlock:^{
[weakSelf showGroupMembersView]; [weakSelf showGroupMembersView];
}], }],
[OWSTableItem itemWithCustomCellBlock:^{ [OWSTableItem
return [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", itemWithCustomCellBlock:^{
UITableViewCell *cell =
[weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION",
@"table cell label in conversation settings") @"table cell label in conversation settings")
iconName:@"table_ic_group_leave"]; iconName:@"table_ic_group_leave"];
cell.userInteractionEnabled = !weakSelf.hasLeftGroup;
return cell;
} }
actionBlock:^{ actionBlock:^{
[weakSelf didTapLeaveGroup]; [weakSelf didTapLeaveGroup];
@ -827,6 +848,11 @@ const CGFloat kIconViewLength = 24;
- (void)conversationNameTouched:(UIGestureRecognizer *)sender - (void)conversationNameTouched:(UIGestureRecognizer *)sender
{ {
if (sender.state == UIGestureRecognizerStateRecognized) { if (sender.state == UIGestureRecognizerStateRecognized) {
if (self.hasLeftGroup) {
DDLogVerbose(@"%@ ignoring tap for left group thread.", self.logTag);
return;
}
if (self.isGroupThread) { if (self.isGroupThread) {
CGPoint location = [sender locationInView:self.avatarView]; CGPoint location = [sender locationInView:self.avatarView];
if (CGRectContainsPoint(self.avatarView.bounds, location)) { if (CGRectContainsPoint(self.avatarView.bounds, location)) {
@ -996,6 +1022,17 @@ const CGFloat kIconViewLength = 24;
[self presentViewController:alertController animated:YES completion:nil]; [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 - (void)leaveGroup
{ {
TSGroupThread *gThread = (TSGroupThread *)self.thread; TSGroupThread *gThread = (TSGroupThread *)self.thread;

Loading…
Cancel
Save