Note to Self.

This commit is contained in:
Matthew Chen 2018-12-21 13:49:42 -05:00
parent 1d13a02927
commit fc8fbebd97
3 changed files with 46 additions and 7 deletions

View File

@ -1258,9 +1258,10 @@ typedef enum : NSUInteger {
} else {
OWSAssertDebug(self.thread.contactIdentifier);
if ([self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]) {
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber];
if (isNoteToSelf) {
name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", "Label for 1:1 conversation with yourself.")
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{
NSFontAttributeName : self.headerView.titlePrimaryFont,
}];

View File

@ -53,6 +53,13 @@ NS_ASSUME_NONNULL_BEGIN
return SSKEnvironment.shared.typingIndicators;
}
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
@ -510,9 +517,18 @@ NS_ASSUME_NONNULL_BEGIN
name = [[NSAttributedString alloc] initWithString:thread.name];
}
} else {
name = [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:thread.contactIdentifier
primaryFont:self.nameFont
secondaryFont:self.nameSecondaryFont];
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber];
if (isNoteToSelf) {
name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{
NSFontAttributeName : self.nameFont,
}];
} else {
name = [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:thread.contactIdentifier
primaryFont:self.nameFont
secondaryFont:self.nameSecondaryFont];
}
}
self.nameLabel.attributedText = name;

View File

@ -61,6 +61,13 @@ const CGFloat kContactCellAvatarTextMargin = 12;
return SSKEnvironment.shared.primaryStorage;
}
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
- (void)configure
@ -133,8 +140,17 @@ const CGFloat kContactCellAvatarTextMargin = 12;
self.thread = [TSContactThread getThreadWithContactId:recipientId transaction:transaction];
}];
self.nameLabel.attributedText =
[self.contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font];
BOOL isNoteToSelf = [recipientId isEqualToString:self.tsAccountManager.localNumber];
if (isNoteToSelf) {
self.nameLabel.attributedText = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{
NSFontAttributeName : self.nameLabel.font,
}];
} else {
self.nameLabel.attributedText =
[self.contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(otherUsersProfileDidChange:)
@ -165,6 +181,12 @@ const CGFloat kContactCellAvatarTextMargin = 12;
threadName = [MessageStrings newGroupDefaultTitle];
}
BOOL isNoteToSelf
= (!thread.isGroupThread && [thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]);
if (isNoteToSelf) {
threadName = NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.");
}
NSAttributedString *attributedText =
[[NSAttributedString alloc] initWithString:threadName
attributes:@{