2017-03-09 07:36:09 +01:00
|
|
|
|
//
|
2018-01-11 19:33:19 +01:00
|
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-03-09 07:36:09 +01:00
|
|
|
|
//
|
2014-10-29 21:58:58 +01:00
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
|
#import "InboxTableViewCell.h"
|
2016-09-21 14:37:51 +02:00
|
|
|
|
#import "OWSAvatarBuilder.h"
|
2017-04-08 16:47:47 +02:00
|
|
|
|
#import "Signal-Swift.h"
|
2017-07-12 16:46:54 +02:00
|
|
|
|
#import "ViewControllerUtils.h"
|
2017-12-01 23:10:14 +01:00
|
|
|
|
#import <SignalMessaging/OWSFormat.h>
|
2017-12-08 19:45:24 +01:00
|
|
|
|
#import <SignalMessaging/OWSUserProfile.h>
|
2017-09-14 17:00:30 +02:00
|
|
|
|
#import <SignalServiceKit/OWSMessageManager.h>
|
2017-07-11 23:56:22 +02:00
|
|
|
|
#import <SignalServiceKit/TSContactThread.h>
|
|
|
|
|
#import <SignalServiceKit/TSGroupThread.h>
|
|
|
|
|
#import <SignalServiceKit/TSThread.h>
|
2016-09-21 14:37:51 +02:00
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
2015-10-31 16:53:32 +01:00
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
#define ARCHIVE_IMAGE_VIEW_WIDTH 22.0f
|
|
|
|
|
#define DELETE_IMAGE_VIEW_WIDTH 19.0f
|
2014-12-06 19:26:01 +01:00
|
|
|
|
#define TIME_LABEL_SIZE 11
|
2014-10-29 21:58:58 +01:00
|
|
|
|
#define DATE_LABEL_SIZE 13
|
2015-01-24 04:26:04 +01:00
|
|
|
|
#define SWIPE_ARCHIVE_OFFSET -50
|
2014-10-29 21:58:58 +01:00
|
|
|
|
|
2017-07-31 22:07:38 +02:00
|
|
|
|
const NSUInteger kAvatarViewDiameter = 52;
|
2017-05-27 17:56:08 +02:00
|
|
|
|
|
2015-10-31 16:53:32 +01:00
|
|
|
|
@interface InboxTableViewCell ()
|
|
|
|
|
|
2017-07-11 23:56:22 +02:00
|
|
|
|
@property (nonatomic) AvatarImageView *avatarView;
|
|
|
|
|
@property (nonatomic) UILabel *nameLabel;
|
|
|
|
|
@property (nonatomic) UILabel *snippetLabel;
|
|
|
|
|
@property (nonatomic) UILabel *timeLabel;
|
|
|
|
|
@property (nonatomic) UIView *unreadBadge;
|
2017-04-25 18:56:37 +02:00
|
|
|
|
@property (nonatomic) UILabel *unreadLabel;
|
2015-10-31 16:53:32 +01:00
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
@property (nonatomic) TSThread *thread;
|
|
|
|
|
@property (nonatomic) OWSContactsManager *contactsManager;
|
2017-07-11 23:56:22 +02:00
|
|
|
|
|
2015-10-31 16:53:32 +01:00
|
|
|
|
@end
|
|
|
|
|
|
2017-04-25 18:56:37 +02:00
|
|
|
|
#pragma mark -
|
|
|
|
|
|
2014-11-21 00:51:23 +01:00
|
|
|
|
@implementation InboxTableViewCell
|
2014-10-29 21:58:58 +01:00
|
|
|
|
|
2017-07-11 23:56:22 +02:00
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
|
|
|
|
|
{
|
|
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
|
|
[self commontInit];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// `[UIView init]` invokes `[self initWithFrame:...]`.
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
|
|
{
|
|
|
|
|
if (self = [super initWithFrame:frame]) {
|
|
|
|
|
[self commontInit];
|
|
|
|
|
}
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
2017-07-11 23:56:22 +02:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)commontInit
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(!self.avatarView);
|
|
|
|
|
|
|
|
|
|
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
|
|
|
|
|
self.preservesSuperviewLayoutMargins = YES;
|
|
|
|
|
self.contentView.preservesSuperviewLayoutMargins = YES;
|
|
|
|
|
|
|
|
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
self.avatarView = [[AvatarImageView alloc] init];
|
|
|
|
|
[self.contentView addSubview:self.avatarView];
|
2017-07-21 16:36:45 +02:00
|
|
|
|
[self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize];
|
|
|
|
|
[self.avatarView autoSetDimension:ALDimensionHeight toSize:self.avatarSize];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.avatarView autoPinLeadingToSuperviewMargin];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.avatarView autoVCenterInSuperview];
|
|
|
|
|
|
|
|
|
|
self.nameLabel = [UILabel new];
|
|
|
|
|
self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
2017-08-23 18:03:36 +02:00
|
|
|
|
self.nameLabel.font = [UIFont ows_boldFontWithSize:14.0f];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.contentView addSubview:self.nameLabel];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.nameLabel autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:13.f];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.nameLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.avatarView];
|
|
|
|
|
[self.nameLabel setContentHuggingHorizontalLow];
|
|
|
|
|
|
|
|
|
|
self.snippetLabel = [UILabel new];
|
|
|
|
|
self.snippetLabel.font = [UIFont ows_regularFontWithSize:14.f];
|
|
|
|
|
self.snippetLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
|
self.snippetLabel.textColor = [UIColor colorWithWhite:2 / 3.f alpha:1.f];
|
|
|
|
|
self.snippetLabel.numberOfLines = 2;
|
|
|
|
|
self.snippetLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
|
[self.contentView addSubview:self.snippetLabel];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.snippetLabel autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:13.f];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.snippetLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.nameLabel withOffset:5.f];
|
|
|
|
|
[self.snippetLabel autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:self.nameLabel];
|
|
|
|
|
[self.snippetLabel setContentHuggingHorizontalLow];
|
|
|
|
|
|
|
|
|
|
self.timeLabel = [UILabel new];
|
|
|
|
|
self.timeLabel.font = [UIFont ows_lightFontWithSize:14.f];
|
|
|
|
|
[self.contentView addSubview:self.timeLabel];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.timeLabel autoPinTrailingToSuperviewMargin];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.timeLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.nameLabel];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.timeLabel autoPinLeadingToTrailingEdgeOfView:self.nameLabel offset:10.f];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.timeLabel setContentHuggingHorizontalHigh];
|
|
|
|
|
[self.timeLabel setCompressionResistanceHigh];
|
|
|
|
|
|
|
|
|
|
const int kunreadBadgeSize = 24;
|
|
|
|
|
self.unreadBadge = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kunreadBadgeSize, kunreadBadgeSize)];
|
|
|
|
|
self.unreadBadge.layer.cornerRadius = kunreadBadgeSize / 2;
|
|
|
|
|
self.unreadBadge.backgroundColor = [UIColor ows_materialBlueColor];
|
|
|
|
|
[self.contentView addSubview:self.unreadBadge];
|
|
|
|
|
[self.unreadBadge autoSetDimension:ALDimensionWidth toSize:kunreadBadgeSize];
|
|
|
|
|
[self.unreadBadge autoSetDimension:ALDimensionHeight toSize:kunreadBadgeSize];
|
2018-04-02 21:31:32 +02:00
|
|
|
|
[self.unreadBadge autoPinTrailingToSuperviewMargin];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
[self.unreadBadge autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.avatarView];
|
|
|
|
|
[self.unreadBadge setContentHuggingHorizontalHigh];
|
|
|
|
|
[self.unreadBadge setCompressionResistanceHigh];
|
|
|
|
|
|
|
|
|
|
self.unreadLabel = [UILabel new];
|
|
|
|
|
self.unreadLabel.font = [UIFont ows_regularFontWithSize:12.f];
|
|
|
|
|
self.unreadLabel.textColor = [UIColor whiteColor];
|
|
|
|
|
self.unreadLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
|
|
|
self.unreadLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
[self.unreadBadge addSubview:self.unreadLabel];
|
|
|
|
|
[self.unreadLabel autoVCenterInSuperview];
|
|
|
|
|
[self.unreadLabel autoPinWidthToSuperview];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSString *)cellReuseIdentifier
|
|
|
|
|
{
|
|
|
|
|
return NSStringFromClass([self class]);
|
2015-09-01 19:22:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 18:56:37 +02:00
|
|
|
|
+ (CGFloat)rowHeight
|
|
|
|
|
{
|
|
|
|
|
return 72.f;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-21 16:36:45 +02:00
|
|
|
|
- (CGFloat)avatarSize
|
|
|
|
|
{
|
|
|
|
|
return 52.f;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 19:22:08 +02:00
|
|
|
|
- (void)initializeLayout {
|
2015-10-31 16:53:32 +01:00
|
|
|
|
self.selectionStyle = UITableViewCellSelectionStyleDefault;
|
2014-10-29 21:58:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-21 14:37:51 +02:00
|
|
|
|
- (nullable NSString *)reuseIdentifier
|
|
|
|
|
{
|
2014-10-29 21:58:58 +01:00
|
|
|
|
return NSStringFromClass(self.class);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-08 16:47:47 +02:00
|
|
|
|
- (void)configureWithThread:(TSThread *)thread
|
|
|
|
|
contactsManager:(OWSContactsManager *)contactsManager
|
|
|
|
|
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
2016-09-21 14:37:51 +02:00
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
|
OWSAssertIsOnMainThread();
|
2017-04-08 16:47:47 +02:00
|
|
|
|
OWSAssert(thread);
|
|
|
|
|
OWSAssert(contactsManager);
|
|
|
|
|
OWSAssert(blockedPhoneNumberSet);
|
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
self.thread = thread;
|
|
|
|
|
self.contactsManager = contactsManager;
|
|
|
|
|
|
2017-04-08 16:47:47 +02:00
|
|
|
|
BOOL isBlocked = NO;
|
|
|
|
|
if (!thread.isGroupThread) {
|
|
|
|
|
NSString *contactIdentifier = thread.contactIdentifier;
|
|
|
|
|
isBlocked = [blockedPhoneNumberSet containsObject:contactIdentifier];
|
2015-01-14 10:51:47 +01:00
|
|
|
|
}
|
2017-08-23 22:41:31 +02:00
|
|
|
|
|
2017-04-19 18:07:52 +02:00
|
|
|
|
NSMutableAttributedString *snippetText = [NSMutableAttributedString new];
|
|
|
|
|
if (isBlocked) {
|
|
|
|
|
// If thread is blocked, don't show a snippet or mute status.
|
|
|
|
|
[snippetText appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION",
|
|
|
|
|
@"A label for conversations with blocked users.")
|
|
|
|
|
attributes:@{
|
|
|
|
|
NSFontAttributeName : [UIFont ows_mediumFontWithSize:12],
|
|
|
|
|
NSForegroundColorAttributeName : [UIColor ows_blackColor],
|
|
|
|
|
}]];
|
|
|
|
|
} else {
|
|
|
|
|
if ([thread isMuted]) {
|
|
|
|
|
[snippetText appendAttributedString:[[NSAttributedString alloc]
|
|
|
|
|
initWithString:@"\ue067 "
|
|
|
|
|
attributes:@{
|
|
|
|
|
NSFontAttributeName : [UIFont ows_elegantIconsFont:9.f],
|
|
|
|
|
NSForegroundColorAttributeName : (thread.hasUnreadMessages
|
|
|
|
|
? [UIColor colorWithWhite:0.1f alpha:1.f]
|
|
|
|
|
: [UIColor lightGrayColor]),
|
|
|
|
|
}]];
|
|
|
|
|
}
|
2018-02-16 02:45:28 +01:00
|
|
|
|
NSString *displayableText = thread.lastMessageLabel.filterStringForDisplay;
|
2017-05-03 16:16:44 +02:00
|
|
|
|
if (displayableText) {
|
|
|
|
|
[snippetText appendAttributedString:[[NSAttributedString alloc]
|
|
|
|
|
initWithString:displayableText
|
|
|
|
|
attributes:@{
|
|
|
|
|
NSFontAttributeName : (thread.hasUnreadMessages
|
|
|
|
|
? [UIFont ows_mediumFontWithSize:12]
|
|
|
|
|
: [UIFont ows_regularFontWithSize:12]),
|
|
|
|
|
NSForegroundColorAttributeName :
|
|
|
|
|
(thread.hasUnreadMessages ? [UIColor ows_blackColor]
|
|
|
|
|
: [UIColor lightGrayColor]),
|
|
|
|
|
}]];
|
|
|
|
|
}
|
2017-04-19 18:07:52 +02:00
|
|
|
|
}
|
2017-03-19 14:44:53 +01:00
|
|
|
|
|
2015-10-31 16:53:32 +01:00
|
|
|
|
NSAttributedString *attributedDate = [self dateAttributedString:thread.lastMessageDate];
|
2018-01-30 21:49:36 +01:00
|
|
|
|
NSUInteger unreadCount = [[OWSMessageUtils sharedManager] unreadMessagesInThread:thread];
|
2017-09-14 17:00:30 +02:00
|
|
|
|
|
2017-04-08 16:47:47 +02:00
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
selector:@selector(otherUsersProfileDidChange:)
|
|
|
|
|
name:kNSNotificationName_OtherUsersProfileDidChange
|
|
|
|
|
object:nil];
|
|
|
|
|
[self updateNameLabel];
|
2017-08-25 18:39:27 +02:00
|
|
|
|
[self updateAvatarView];
|
|
|
|
|
|
2017-04-19 18:07:52 +02:00
|
|
|
|
self.snippetLabel.attributedText = snippetText;
|
2017-04-08 16:47:47 +02:00
|
|
|
|
self.timeLabel.attributedText = attributedDate;
|
|
|
|
|
|
2017-07-21 16:36:45 +02:00
|
|
|
|
self.separatorInset = UIEdgeInsetsMake(0, self.avatarSize * 1.5f, 0, 0);
|
2017-04-08 16:47:47 +02:00
|
|
|
|
|
2017-08-23 21:41:56 +02:00
|
|
|
|
_timeLabel.textColor = thread.hasUnreadMessages ? [UIColor ows_materialBlueColor] : [UIColor ows_darkGrayColor];
|
|
|
|
|
|
2017-07-11 23:56:22 +02:00
|
|
|
|
if (unreadCount > 0) {
|
|
|
|
|
self.unreadBadge.hidden = NO;
|
|
|
|
|
self.unreadLabel.hidden = NO;
|
2017-12-01 23:10:14 +01:00
|
|
|
|
self.unreadLabel.text = [OWSFormat formatInt:MIN(99, (int)unreadCount)];
|
2017-07-11 23:56:22 +02:00
|
|
|
|
} else {
|
|
|
|
|
self.unreadBadge.hidden = YES;
|
|
|
|
|
self.unreadLabel.hidden = YES;
|
|
|
|
|
}
|
2017-08-25 18:39:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateAvatarView
|
|
|
|
|
{
|
|
|
|
|
OWSContactsManager *contactsManager = self.contactsManager;
|
|
|
|
|
if (contactsManager == nil) {
|
|
|
|
|
OWSFail(@"%@ contactsManager should not be nil", self.logTag);
|
|
|
|
|
self.avatarView.image = nil;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSThread *thread = self.thread;
|
|
|
|
|
if (thread == nil) {
|
|
|
|
|
OWSFail(@"%@ thread should not be nil", self.logTag);
|
|
|
|
|
self.avatarView.image = nil;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-04-08 16:47:47 +02:00
|
|
|
|
|
2017-07-31 22:07:38 +02:00
|
|
|
|
self.avatarView.image =
|
|
|
|
|
[OWSAvatarBuilder buildImageForThread:thread diameter:kAvatarViewDiameter contactsManager:contactsManager];
|
2014-10-29 21:58:58 +01:00
|
|
|
|
}
|
2017-09-08 16:28:21 +02:00
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
#pragma mark - Date formatting
|
|
|
|
|
|
2018-02-21 17:18:58 +01:00
|
|
|
|
- (NSAttributedString *)dateAttributedString:(nullable NSDate *)date
|
|
|
|
|
{
|
|
|
|
|
if (date == nil) {
|
|
|
|
|
OWSProdLogAndFail(@"%@ date was unexpectedly nil", self.logTag);
|
|
|
|
|
return [NSAttributedString new];
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-12 23:08:57 +01:00
|
|
|
|
NSString *timeString;
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
2015-03-29 16:51:46 +02:00
|
|
|
|
if ([DateUtil dateIsToday:date]) {
|
2015-02-12 23:08:57 +01:00
|
|
|
|
timeString = [[DateUtil timeFormatter] stringFromDate:date];
|
|
|
|
|
} else {
|
|
|
|
|
timeString = [[DateUtil dateFormatter] stringFromDate:date];
|
|
|
|
|
}
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
2018-02-21 17:18:58 +01:00
|
|
|
|
OWSAssert(timeString);
|
2014-10-29 21:58:58 +01:00
|
|
|
|
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:timeString];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
[attributedString addAttribute:NSForegroundColorAttributeName
|
2014-11-29 19:54:33 +01:00
|
|
|
|
value:[UIColor ows_darkGrayColor]
|
2014-10-29 21:58:58 +01:00
|
|
|
|
range:NSMakeRange(0, timeString.length)];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
[attributedString addAttribute:NSFontAttributeName
|
2015-01-14 22:30:01 +01:00
|
|
|
|
value:[UIFont ows_regularFontWithSize:TIME_LABEL_SIZE]
|
2014-10-29 21:58:58 +01:00
|
|
|
|
range:NSMakeRange(0, timeString.length)];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
|
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
return attributedString;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-11 23:56:22 +02:00
|
|
|
|
- (void)prepareForReuse
|
|
|
|
|
{
|
|
|
|
|
[super prepareForReuse];
|
2017-11-08 18:56:55 +01:00
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
2014-10-29 21:58:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
#pragma mark - Name
|
|
|
|
|
|
|
|
|
|
- (void)otherUsersProfileDidChange:(NSNotification *)notification
|
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
|
|
|
|
|
if (recipientId.length == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (![self.thread isKindOfClass:[TSContactThread class]]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (![self.thread.contactIdentifier isEqualToString:recipientId]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self updateNameLabel];
|
2017-08-25 18:39:27 +02:00
|
|
|
|
[self updateAvatarView];
|
2017-08-23 22:41:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)updateNameLabel
|
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
2017-08-23 22:41:31 +02:00
|
|
|
|
TSThread *thread = self.thread;
|
|
|
|
|
if (thread == nil) {
|
|
|
|
|
OWSFail(@"%@ thread should not be nil", self.logTag);
|
|
|
|
|
self.nameLabel.attributedText = nil;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OWSContactsManager *contactsManager = self.contactsManager;
|
|
|
|
|
if (contactsManager == nil) {
|
|
|
|
|
OWSFail(@"%@ contacts manager should not be nil", self.logTag);
|
|
|
|
|
self.nameLabel.attributedText = nil;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSAttributedString *name;
|
|
|
|
|
if (thread.isGroupThread) {
|
|
|
|
|
if (thread.name.length == 0) {
|
2017-10-14 19:20:46 +02:00
|
|
|
|
name = [[NSAttributedString alloc] initWithString:[MessageStrings newGroupDefaultTitle]];
|
2017-08-23 22:41:31 +02:00
|
|
|
|
} else {
|
|
|
|
|
name = [[NSAttributedString alloc] initWithString:thread.name];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
name = [contactsManager attributedStringForConversationTitleWithPhoneIdentifier:thread.contactIdentifier
|
|
|
|
|
primaryFont:self.nameLabel.font
|
|
|
|
|
secondaryFont:[UIFont ows_footnoteFont]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.nameLabel.attributedText = name;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
|
@end
|
2016-09-21 14:37:51 +02:00
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|