Note to Self.

pull/1/head
Matthew Chen 6 years ago
parent f2e44487ae
commit e52feb3c36

@ -302,6 +302,13 @@ typedef enum : NSUInteger {
return SSKEnvironment.shared.attachmentDownloads;
}
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
- (void)addNotificationListeners
@ -490,7 +497,7 @@ typedef enum : NSUInteger {
}
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
return ![groupThread.groupModel.groupMemberIds containsObject:[TSAccountManager localNumber]];
return ![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber];
}
- (void)hideInputIfNeeded
@ -1250,11 +1257,20 @@ typedef enum : NSUInteger {
}
} else {
OWSAssertDebug(self.thread.contactIdentifier);
name =
[self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:self.thread.contactIdentifier
if ([self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]) {
name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", "Label for 1:1 conversation with yourself.")
attributes:@{
NSFontAttributeName : self.headerView.titlePrimaryFont,
}];
} else {
name = [self.contactsManager
attributedContactOrProfileNameForPhoneIdentifier:self.thread.contactIdentifier
primaryFont:self.headerView.titlePrimaryFont
secondaryFont:self.headerView.titleSecondaryFont];
}
}
self.title = nil;
if ([name isEqual:self.headerView.attributedTitle]) {
@ -1557,7 +1573,7 @@ typedef enum : NSUInteger {
- (BOOL)canCall
{
return !(self.isGroupConversation ||
[((TSContactThread *)self.thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]]);
[((TSContactThread *)self.thread).contactIdentifier isEqualToString:self.tsAccountManager.localNumber]);
}
#pragma mark - Dynamic Text
@ -3807,7 +3823,7 @@ typedef enum : NSUInteger {
OWSAssertDebug(groupModel);
NSMutableSet *groupMemberIds = [NSMutableSet setWithArray:groupModel.groupMemberIds];
[groupMemberIds addObject:[TSAccountManager localNumber]];
[groupMemberIds addObject:self.tsAccountManager.localNumber];
groupModel.groupMemberIds = [NSMutableArray arrayWithArray:[groupMemberIds allObjects]];
[self updateGroupModelTo:groupModel successCompletion:nil];
}

@ -55,10 +55,6 @@ const CGFloat kIconViewLength = 24;
@property (nonatomic) NSArray<NSNumber *> *disappearingMessagesDurations;
@property (nonatomic) OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
@property (nullable, nonatomic) MediaGallery *mediaGallery;
@property (nonatomic, readonly) TSAccountManager *accountManager;
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
@property (nonatomic, readonly) OWSMessageSender *messageSender;
@property (nonatomic, readonly) OWSBlockingManager *blockingManager;
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
@property (nonatomic, readonly) UIImageView *avatarView;
@property (nonatomic, readonly) UILabel *disappearingMessagesDurationLabel;
@ -110,10 +106,6 @@ const CGFloat kIconViewLength = 24;
- (void)commonInit
{
_accountManager = [TSAccountManager sharedInstance];
_contactsManager = Environment.shared.contactsManager;
_messageSender = SSKEnvironment.shared.messageSender;
_blockingManager = [OWSBlockingManager sharedManager];
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
[self observeNotifications];
@ -131,6 +123,33 @@ const CGFloat kIconViewLength = 24;
return SSKEnvironment.shared.messageSenderJobQueue;
}
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
- (OWSContactsManager *)contactsManager
{
return Environment.shared.contactsManager;
}
- (OWSMessageSender *)messageSender
{
return SSKEnvironment.shared.messageSender;
}
- (OWSBlockingManager *)blockingManager
{
return [OWSBlockingManager sharedManager];
}
- (OWSProfileManager *)profileManager
{
return [OWSProfileManager sharedManager];
}
#pragma mark
- (void)observeNotifications
@ -291,6 +310,9 @@ const CGFloat kIconViewLength = 24;
OWSTableContents *contents = [OWSTableContents new];
contents.title = NSLocalizedString(@"CONVERSATION_SETTINGS", @"title for conversation settings screen");
BOOL isNoteToSelf = (!self.thread.isGroupThread &&
[self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]);
__weak OWSConversationSettingsViewController *weakSelf = self;
// Main section.
@ -333,7 +355,7 @@ const CGFloat kIconViewLength = 24;
}]];
}
if (!self.isGroupThread && self.thread.hasSafetyNumbers) {
if (!isNoteToSelf && !self.isGroupThread && self.thread.hasSafetyNumbers) {
[mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
return [weakSelf
disclosureCellWithName:
@ -346,7 +368,9 @@ const CGFloat kIconViewLength = 24;
}]];
}
if ([OWSProfileManager.sharedManager isThreadInProfileWhitelist:self.thread]) {
if (isNoteToSelf) {
// Skip the profile whitelist.
} else if ([self.profileManager isThreadInProfileWhitelist:self.thread]) {
[mainSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
@ -564,6 +588,7 @@ const CGFloat kIconViewLength = 24;
// Mute thread section.
if (!isNoteToSelf) {
OWSTableSection *notificationsSection = [OWSTableSection new];
// We need a section header to separate the notifications UI from the group settings UI.
notificationsSection.headerTitle = NSLocalizedString(
@ -609,7 +634,8 @@ const CGFloat kIconViewLength = 24;
}]];
[notificationsSection
addItem:[OWSTableItem
addItem:
[OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell =
[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
@ -672,12 +698,13 @@ const CGFloat kIconViewLength = 24;
actionBlock:^{
[weakSelf showMuteUnmuteActionSheet];
}]];
notificationsSection.footerTitle
= NSLocalizedString(@"MUTE_BEHAVIOR_EXPLANATION", @"An explanation of the consequences of muting a thread.");
notificationsSection.footerTitle = NSLocalizedString(
@"MUTE_BEHAVIOR_EXPLANATION", @"An explanation of the consequences of muting a thread.");
[contents addSection:notificationsSection];
}
// Block Conversation section.
if (!isNoteToSelf) {
OWSTableSection *section = [OWSTableSection new];
if (self.thread.isGroupThread) {
section.footerTitle = NSLocalizedString(
@ -718,6 +745,7 @@ const CGFloat kIconViewLength = 24;
}
actionBlock:nil]];
[contents addSection:section];
}
self.contents = contents;
}
@ -961,7 +989,7 @@ const CGFloat kIconViewLength = 24;
- (void)showShareProfileAlert
{
[OWSProfileManager.sharedManager presentAddThreadToProfileWhitelist:self.thread
[self.profileManager presentAddThreadToProfileWhitelist:self.thread
fromViewController:self
success:^{
[self updateTableContents];
@ -1118,8 +1146,8 @@ const CGFloat kIconViewLength = 24;
}
[BlockListUIUtils showUnblockThreadActionSheet:self.thread
fromViewController:self
blockingManager:_blockingManager
contactsManager:_contactsManager
blockingManager:self.blockingManager
contactsManager:self.contactsManager
completionBlock:^(BOOL isBlocked) {
// Update switch state if user cancels action.
blockConversationSwitch.on = isBlocked;

@ -1466,6 +1466,9 @@
/* Label for a button that lets users search for contacts by phone number */
"NO_CONTACTS_SEARCH_BY_PHONE_NUMBER" = "Find Contacts by Phone Number";
/* Label for 1:1 conversation with yourself. */
"NOTE_TO_SELF" = "Note to Self";
/* Lock screen notification text presented after user powers on their device without unlocking. Embeds {{device model}} (either 'iPad' or 'iPhone') */
"NOTIFICATION_BODY_PHONE_LOCKED_FORMAT" = "You may have received messages while your %@ was restarting.";

Loading…
Cancel
Save