|
|
@ -27,7 +27,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@property (nonatomic) UILabel *unreadLabel;
|
|
|
|
@property (nonatomic) UILabel *unreadLabel;
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, nullable) ThreadViewModel *thread;
|
|
|
|
@property (nonatomic, nullable) ThreadViewModel *thread;
|
|
|
|
@property (nonatomic, nullable) OWSContactsManager *contactsManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
|
|
|
@property (nonatomic, readonly) NSMutableArray<NSLayoutConstraint *> *viewConstraints;
|
|
|
|
|
|
|
|
|
|
|
@ -37,6 +36,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@implementation HomeViewCell
|
|
|
|
@implementation HomeViewCell
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (OWSContactsManager *)contactsManager
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OWSAssertDebug(Environment.shared.contactsManager);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Environment.shared.contactsManager;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
@ -167,30 +177,25 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
|
|
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
|
|
|
contactsManager:(OWSContactsManager *)contactsManager
|
|
|
|
|
|
|
|
isBlocked:(BOOL)isBlocked
|
|
|
|
isBlocked:(BOOL)isBlocked
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[self configureWithThread:thread
|
|
|
|
[self configureWithThread:thread
|
|
|
|
contactsManager:contactsManager
|
|
|
|
|
|
|
|
isBlocked:isBlocked
|
|
|
|
isBlocked:isBlocked
|
|
|
|
overrideSnippet:nil
|
|
|
|
overrideSnippet:nil
|
|
|
|
overrideDate:nil];
|
|
|
|
overrideDate:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
|
|
|
- (void)configureWithThread:(ThreadViewModel *)thread
|
|
|
|
contactsManager:(OWSContactsManager *)contactsManager
|
|
|
|
|
|
|
|
isBlocked:(BOOL)isBlocked
|
|
|
|
isBlocked:(BOOL)isBlocked
|
|
|
|
overrideSnippet:(nullable NSAttributedString *)overrideSnippet
|
|
|
|
overrideSnippet:(nullable NSAttributedString *)overrideSnippet
|
|
|
|
overrideDate:(nullable NSDate *)overrideDate
|
|
|
|
overrideDate:(nullable NSDate *)overrideDate
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertDebug(thread);
|
|
|
|
OWSAssertDebug(thread);
|
|
|
|
OWSAssertDebug(contactsManager);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[OWSTableItem configureCell:self];
|
|
|
|
[OWSTableItem configureCell:self];
|
|
|
|
|
|
|
|
|
|
|
|
self.thread = thread;
|
|
|
|
self.thread = thread;
|
|
|
|
self.contactsManager = contactsManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL hasUnreadMessages = thread.hasUnreadMessages;
|
|
|
|
BOOL hasUnreadMessages = thread.hasUnreadMessages;
|
|
|
|
|
|
|
|
|
|
|
@ -321,13 +326,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
- (void)updateAvatarView
|
|
|
|
- (void)updateAvatarView
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSContactsManager *contactsManager = self.contactsManager;
|
|
|
|
|
|
|
|
if (contactsManager == nil) {
|
|
|
|
|
|
|
|
OWSFailDebug(@"contactsManager should not be nil");
|
|
|
|
|
|
|
|
self.avatarView.image = nil;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThreadViewModel *thread = self.thread;
|
|
|
|
ThreadViewModel *thread = self.thread;
|
|
|
|
if (thread == nil) {
|
|
|
|
if (thread == nil) {
|
|
|
|
OWSFailDebug(@"thread should not be nil");
|
|
|
|
OWSFailDebug(@"thread should not be nil");
|
|
|
@ -444,7 +442,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[self.viewConstraints removeAllObjects];
|
|
|
|
[self.viewConstraints removeAllObjects];
|
|
|
|
|
|
|
|
|
|
|
|
self.thread = nil;
|
|
|
|
self.thread = nil;
|
|
|
|
self.contactsManager = nil;
|
|
|
|
|
|
|
|
self.avatarView.image = nil;
|
|
|
|
self.avatarView.image = nil;
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
@ -487,13 +484,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OWSContactsManager *contactsManager = self.contactsManager;
|
|
|
|
|
|
|
|
if (contactsManager == nil) {
|
|
|
|
|
|
|
|
OWSFailDebug(@"contacts manager should not be nil");
|
|
|
|
|
|
|
|
self.nameLabel.attributedText = nil;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSAttributedString *name;
|
|
|
|
NSAttributedString *name;
|
|
|
|
if (thread.isGroupThread) {
|
|
|
|
if (thread.isGroupThread) {
|
|
|
|
if (thread.name.length == 0) {
|
|
|
|
if (thread.name.length == 0) {
|
|
|
@ -502,7 +492,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
name = [[NSAttributedString alloc] initWithString:thread.name];
|
|
|
|
name = [[NSAttributedString alloc] initWithString:thread.name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
name = [contactsManager attributedContactOrProfileNameForPhoneIdentifier:thread.contactIdentifier
|
|
|
|
name = [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:thread.contactIdentifier
|
|
|
|
primaryFont:self.nameFont
|
|
|
|
primaryFont:self.nameFont
|
|
|
|
secondaryFont:self.nameSecondaryFont];
|
|
|
|
secondaryFont:self.nameSecondaryFont];
|
|
|
|
}
|
|
|
|
}
|
|
|
|