From 542d5826de50935604223331c2270195daee9b01 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 14 Nov 2018 18:53:26 -0600 Subject: [PATCH 1/2] fix a million retain cycles in conversation settings --- .../OWSConversationSettingsViewController.m | 63 ++++++++++++------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index aa16a1fa9..a1c0edcbe 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -347,30 +347,40 @@ const CGFloat kIconViewLength = 24; } if ([OWSProfileManager.sharedManager isThreadInProfileWhitelist:self.thread]) { - [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf - labelCellWithName:(self.isGroupThread - ? NSLocalizedString( - @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP", - @"Indicates that user's profile has been shared with a group.") - : NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER", - @"Indicates that user's profile has been shared with a user."))iconName - :@"table_ic_share_profile"]; - } - actionBlock:nil]]; + [mainSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + OWSConversationSettingsViewController *strongSelf = weakSelf; + OWSCAssertDebug(strongSelf); + + return [strongSelf + labelCellWithName: + (strongSelf.isGroupThread + ? NSLocalizedString( + @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP", + @"Indicates that user's profile has been shared with a group.") + : NSLocalizedString( + @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER", + @"Indicates that user's profile has been shared with a user.")) + iconName:@"table_ic_share_profile"]; + } + actionBlock:nil]]; } else { [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [weakSelf + OWSConversationSettingsViewController *strongSelf = weakSelf; + OWSCAssertDebug(strongSelf); + + UITableViewCell *cell = [strongSelf disclosureCellWithName: - (self.isGroupThread + (strongSelf.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; + cell.userInteractionEnabled = !strongSelf.hasLeftGroup; return cell; } @@ -408,7 +418,7 @@ const CGFloat kIconViewLength = 24; UIStackView *topRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel, switchView ]]; - topRow.spacing = self.iconSpacing; + topRow.spacing = strongSelf.iconSpacing; topRow.alignment = UIStackViewAlignmentCenter; [cell.contentView addSubview:topRow]; [topRow autoPinEdgesToSuperviewMarginsExcludingEdge:ALEdgeBottom]; @@ -455,7 +465,7 @@ const CGFloat kIconViewLength = 24; UIStackView *topRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel ]]; - topRow.spacing = self.iconSpacing; + topRow.spacing = strongSelf.iconSpacing; topRow.alignment = UIStackViewAlignmentCenter; [cell.contentView addSubview:topRow]; [topRow autoPinEdgesToSuperviewMarginsExcludingEdge:ALEdgeBottom]; @@ -485,13 +495,17 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - ConversationColorName colorName = self.thread.conversationColorName; + OWSConversationSettingsViewController *strongSelf = weakSelf; + OWSCAssertDebug(strongSelf); + + ConversationColorName colorName = strongSelf.thread.conversationColorName; UIColor *currentColor = [OWSConversationColor conversationColorOrDefaultForColorName:colorName].themeColor; NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR", @"Label for table cell which leads to picking a new conversation color"); - return - [weakSelf cellWithName:title iconName:@"ic_color_palette" disclosureIconColor:currentColor]; + return [strongSelf cellWithName:title + iconName:@"ic_color_palette" + disclosureIconColor:currentColor]; } actionBlock:^{ [weakSelf showColorPicker]; @@ -578,12 +592,12 @@ const CGFloat kIconViewLength = 24; UIStackView *contentRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel ]]; - contentRow.spacing = self.iconSpacing; + contentRow.spacing = strongSelf.iconSpacing; contentRow.alignment = UIStackViewAlignmentCenter; [cell.contentView addSubview:contentRow]; [contentRow autoPinEdgesToSuperviewMargins]; - OWSSound sound = [OWSSounds notificationSoundForThread:self.thread]; + OWSSound sound = [OWSSounds notificationSoundForThread:strongSelf.thread]; cell.detailTextLabel.text = [OWSSounds displayNameForSound:sound]; return cell; } @@ -646,7 +660,7 @@ const CGFloat kIconViewLength = 24; UIStackView *contentRow = [[UIStackView alloc] initWithArrangedSubviews:@[ iconView, rowLabel ]]; - contentRow.spacing = self.iconSpacing; + contentRow.spacing = strongSelf.iconSpacing; contentRow.alignment = UIStackViewAlignmentCenter; [cell.contentView addSubview:contentRow]; [contentRow autoPinEdgesToSuperviewMargins]; @@ -681,7 +695,7 @@ const CGFloat kIconViewLength = 24; } NSString *cellTitle; - if (self.thread.isGroupThread) { + if (strongSelf.thread.isGroupThread) { cellTitle = NSLocalizedString(@"CONVERSATION_SETTINGS_BLOCK_THIS_GROUP", @"table cell label in conversation settings"); } else { @@ -694,7 +708,8 @@ const CGFloat kIconViewLength = 24; cell.selectionStyle = UITableViewCellSelectionStyleNone; UISwitch *blockConversationSwitch = [UISwitch new]; - blockConversationSwitch.on = [strongSelf.blockingManager isThreadBlocked:self.thread]; + blockConversationSwitch.on = + [strongSelf.blockingManager isThreadBlocked:strongSelf.thread]; [blockConversationSwitch addTarget:strongSelf action:@selector(blockConversationSwitchDidChange:) forControlEvents:UIControlEventValueChanged]; From f6e9fce0d3ba088d7768cbdbf14d07bc7162a0ea Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 14 Nov 2018 18:53:58 -0600 Subject: [PATCH 2/2] fix All Media button from conversation settings --- .../ThreadSettings/OWSConversationSettingsViewController.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index a1c0edcbe..e144c74a8 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -54,7 +54,7 @@ const CGFloat kIconViewLength = 24; @property (nonatomic) NSArray *disappearingMessagesDurations; @property (nonatomic) OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration; -@property (nullable, nonatomic) MediaGalleryNavigationController *mediaGalleryViewController; +@property (nullable, nonatomic) MediaGallery *mediaGallery; @property (nonatomic, readonly) TSAccountManager *accountManager; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) OWSMessageSender *messageSender; @@ -1294,13 +1294,12 @@ const CGFloat kIconViewLength = 24; uiDatabaseConnection:self.uiDatabaseConnection options:MediaGalleryOptionSliderEnabled]; - // although we don't present the mediaGalleryViewController directly, we need to maintain a strong - // reference to it until we're dismissed. - self.mediaGalleryViewController = mediaGallery.navigationController; + self.mediaGallery = mediaGallery; OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]); [mediaGallery pushTileViewFromNavController:(OWSNavigationController *)self.navigationController]; } + #pragma mark - Notifications - (void)identityStateDidChange:(NSNotification *)notification