diff --git a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m index 601276b87..5d6d7a82a 100644 --- a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m +++ b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m @@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN addItem:[OWSTableItem itemWithCustomCellBlock:^{ ContactTableViewCell *cell = [ContactTableViewCell new]; - [cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:phoneNumber]; return cell; } customRowHeight:UITableViewAutomaticDimension diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 092235622..9f8fa79cc 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -228,7 +228,7 @@ class ConversationSearchViewController: UITableViewController, BlockListCacheDel owsFailDebug("searchResult was unexpectedly nil") return UITableViewCell() } - cell.configure(withRecipientId: searchResult.signalAccount.recipientId, contactsManager: contactsManager) + cell.configure(withRecipientId: searchResult.signalAccount.recipientId) return cell case .messages: guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else { diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index b08d9802d..88b233142 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -274,7 +274,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele } else { cellView.accessoryMessage = shortStatusMessage } - cellView.configure(withRecipientId: recipientId, contactsManager: self.contactsManager) + cellView.configure(withRecipientId: recipientId) let wrapper = UIView() wrapper.layoutMargins = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20) diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index e0bbd9507..3de626be8 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -470,8 +470,7 @@ NS_ASSUME_NONNULL_BEGIN @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:signalAccount.recipientId - contactsManager:self.contactsViewHelper.contactsManager]; + [cell configureWithRecipientId:signalAccount.recipientId]; return cell; } @@ -518,7 +517,7 @@ NS_ASSUME_NONNULL_BEGIN cell.accessoryMessage = NSLocalizedString( @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:phoneNumber]; return cell; } customRowHeight:UITableViewAutomaticDimension @@ -566,8 +565,7 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:signalAccount.recipientId - contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:signalAccount.recipientId]; return cell; } diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 33bda1c69..681687fa1 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -243,8 +243,7 @@ NS_ASSUME_NONNULL_BEGIN cell.accessoryMessage = NSLocalizedString( @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:recipientId - contactsManager:contactsViewHelper.contactsManager]; + [cell configureWithRecipientId:recipientId]; return cell; } customRowHeight:UITableViewAutomaticDimension @@ -332,8 +331,7 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:signalAccount.recipientId - contactsManager:contactsViewHelper.contactsManager]; + [cell configureWithRecipientId:signalAccount.recipientId]; return cell; } customRowHeight:UITableViewAutomaticDimension diff --git a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m index e6d7e0734..5bdcc30dc 100644 --- a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m @@ -188,7 +188,7 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:recipientId]; if (isVerified) { [cell setAttributedSubtitle:cell.verifiedSubtitle]; diff --git a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m index 9a2cbd2fa..3f44b0693 100644 --- a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m @@ -283,8 +283,7 @@ NS_ASSUME_NONNULL_BEGIN @"An indicator that a user is a new member of the group."); } - [cell configureWithRecipientId:recipientId - contactsManager:contactsViewHelper.contactsManager]; + [cell configureWithRecipientId:recipientId]; return cell; } customRowHeight:UITableViewAutomaticDimension diff --git a/SignalMessaging/ViewControllers/SelectRecipientViewController.m b/SignalMessaging/ViewControllers/SelectRecipientViewController.m index 16b64570a..b8d0e7a98 100644 --- a/SignalMessaging/ViewControllers/SelectRecipientViewController.m +++ b/SignalMessaging/ViewControllers/SelectRecipientViewController.m @@ -9,7 +9,6 @@ #import #import #import -#import #import #import #import @@ -549,8 +548,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien cell.accessoryMessage = [weakSelf.delegate accessoryMessageForSignalAccount:signalAccount]; } - [cell configureWithRecipientId:signalAccount.recipientId - contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:signalAccount.recipientId]; if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { cell.selectionStyle = UITableViewCellSelectionStyleNone; diff --git a/SignalMessaging/ViewControllers/SelectThreadViewController.m b/SignalMessaging/ViewControllers/SelectThreadViewController.m index 6f02e3dc6..8c1a403a7 100644 --- a/SignalMessaging/ViewControllers/SelectThreadViewController.m +++ b/SignalMessaging/ViewControllers/SelectThreadViewController.m @@ -203,7 +203,7 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithThread:thread contactsManager:helper.contactsManager]; + [cell configureWithThread:thread]; if (!cell.hasAccessoryText) { // Don't add a disappearing messages indicator if we've already added a "blocked" label. @@ -277,8 +277,7 @@ NS_ASSUME_NONNULL_BEGIN cell.accessoryMessage = NSLocalizedString( @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } - [cell configureWithRecipientId:signalAccount.recipientId - contactsManager:helper.contactsManager]; + [cell configureWithRecipientId:signalAccount.recipientId]; return cell; } customRowHeight:UITableViewAutomaticDimension diff --git a/SignalMessaging/Views/ContactCellView.h b/SignalMessaging/Views/ContactCellView.h index 08e9fdef1..bf1c77254 100644 --- a/SignalMessaging/Views/ContactCellView.h +++ b/SignalMessaging/Views/ContactCellView.h @@ -6,16 +6,15 @@ NS_ASSUME_NONNULL_BEGIN extern const CGFloat kContactCellAvatarTextMargin; -@class OWSContactsManager; @class TSThread; @interface ContactCellView : UIStackView @property (nonatomic, nullable) NSString *accessoryMessage; -- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; +- (void)configureWithRecipientId:(NSString *)recipientId; -- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager; +- (void)configureWithThread:(TSThread *)thread; - (void)prepareForReuse; diff --git a/SignalMessaging/Views/ContactCellView.m b/SignalMessaging/Views/ContactCellView.m index aef302c6b..0d694155f 100644 --- a/SignalMessaging/Views/ContactCellView.m +++ b/SignalMessaging/Views/ContactCellView.m @@ -8,6 +8,7 @@ #import "UIFont+OWS.h" #import "UIView+OWS.h" #import +#import #import #import #import @@ -27,7 +28,6 @@ const CGFloat kContactCellAvatarTextMargin = 12; @property (nonatomic) UIStackView *nameContainerView; @property (nonatomic) UIView *accessoryViewContainer; -@property (nonatomic) OWSContactsManager *contactsManager; @property (nonatomic, nullable) TSThread *thread; @property (nonatomic) NSString *recipientId; @@ -45,6 +45,24 @@ const CGFloat kContactCellAvatarTextMargin = 12; return self; } +#pragma mark - Dependencies + +- (OWSContactsManager *)contactsManager +{ + OWSAssertDebug(Environment.shared.contactsManager); + + return Environment.shared.contactsManager; +} + +- (OWSPrimaryStorage *)primaryStorage +{ + OWSAssertDebug(SSKEnvironment.shared.primaryStorage); + + return SSKEnvironment.shared.primaryStorage; +} + +#pragma mark - + - (void)configure { OWSAssertDebug(!self.nameLabel); @@ -102,19 +120,17 @@ const CGFloat kContactCellAvatarTextMargin = 12; self.accessoryLabel.textColor = Theme.middleGrayColor; } -- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager +- (void)configureWithRecipientId:(NSString *)recipientId { OWSAssertDebug(recipientId.length > 0); - OWSAssertDebug(contactsManager); // Update fonts to reflect changes to dynamic type. [self configureFontsAndColors]; self.recipientId = recipientId; - self.contactsManager = contactsManager; self.nameLabel.attributedText = - [contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font]; + [self.contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(otherUsersProfileDidChange:) @@ -132,7 +148,7 @@ const CGFloat kContactCellAvatarTextMargin = 12; [self layoutSubviews]; } -- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager +- (void)configureWithThread:(TSThread *)thread { OWSAssertDebug(thread); self.thread = thread; @@ -140,8 +156,6 @@ const CGFloat kContactCellAvatarTextMargin = 12; // Update fonts to reflect changes to dynamic type. [self configureFontsAndColors]; - self.contactsManager = contactsManager; - NSString *threadName = thread.name; if (threadName.length == 0 && [thread isKindOfClass:[TSGroupThread class]]) { threadName = [MessageStrings newGroupDefaultTitle]; diff --git a/SignalMessaging/Views/ContactTableViewCell.h b/SignalMessaging/Views/ContactTableViewCell.h index 778f8a6c1..5183609a0 100644 --- a/SignalMessaging/Views/ContactTableViewCell.h +++ b/SignalMessaging/Views/ContactTableViewCell.h @@ -2,20 +2,17 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSContactsManager.h" - NS_ASSUME_NONNULL_BEGIN -@class OWSContactsManager; @class TSThread; @interface ContactTableViewCell : UITableViewCell + (NSString *)reuseIdentifier; -- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; +- (void)configureWithRecipientId:(NSString *)recipientId; -- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager; +- (void)configureWithThread:(TSThread *)thread; // This method should be called _before_ the configure... methods. - (void)setAccessoryMessage:(nullable NSString *)accessoryMessage; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 862966824..5c7434097 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -53,23 +53,23 @@ NS_ASSUME_NONNULL_BEGIN self.cellView.userInteractionEnabled = NO; } -- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager +- (void)configureWithRecipientId:(NSString *)recipientId { [OWSTableItem configureCell:self]; - [self.cellView configureWithRecipientId:recipientId contactsManager:contactsManager]; + [self.cellView configureWithRecipientId:recipientId]; // Force layout, since imageView isn't being initally rendered on App Store optimized build. [self layoutSubviews]; } -- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager +- (void)configureWithThread:(TSThread *)thread { OWSAssertDebug(thread); [OWSTableItem configureCell:self]; - [self.cellView configureWithThread:thread contactsManager:contactsManager]; + [self.cellView configureWithThread:thread]; // Force layout, since imageView isn't being initally rendered on App Store optimized build. [self layoutSubviews]; diff --git a/SignalMessaging/utils/OWSContactAvatarBuilder.m b/SignalMessaging/utils/OWSContactAvatarBuilder.m index ec6f72db8..24860f7ca 100644 --- a/SignalMessaging/utils/OWSContactAvatarBuilder.m +++ b/SignalMessaging/utils/OWSContactAvatarBuilder.m @@ -100,11 +100,12 @@ NS_ASSUME_NONNULL_BEGIN - (nullable UIImage *)buildDefaultImage { - UIImage *_Nullable cachedAvatar = - [OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey diameter:(CGFloat)self.diameter]; - if (cachedAvatar) { - return cachedAvatar; - } + UIImage *_Nullable cachedAvatar = nil; + // [OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey + // diameter:(CGFloat)self.diameter]; + // if (cachedAvatar) { + // return cachedAvatar; + // } NSMutableString *initials = [NSMutableString string];