From 7878c0fac80c51efb10a664b5272f56f04a1584b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 18 Jan 2019 17:22:12 -0500 Subject: [PATCH] Add feature flag for 'note to self'. --- SignalMessaging/Views/ContactCellView.m | 4 ++-- SignalMessaging/utils/ConversationSearcher.swift | 10 +++++----- SignalServiceKit/src/Contacts/TSThread.h | 2 ++ SignalServiceKit/src/Contacts/TSThread.m | 8 ++++++++ .../src/Storage/FullTextSearchFinder.swift | 11 ++++++----- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/SignalMessaging/Views/ContactCellView.m b/SignalMessaging/Views/ContactCellView.m index 5d744681b..4421d7688 100644 --- a/SignalMessaging/Views/ContactCellView.m +++ b/SignalMessaging/Views/ContactCellView.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "ContactCellView.h" @@ -140,7 +140,7 @@ const CGFloat kContactCellAvatarTextMargin = 12; self.thread = [TSContactThread getThreadWithContactId:recipientId transaction:transaction]; }]; - BOOL isNoteToSelf = [recipientId isEqualToString:self.tsAccountManager.localNumber]; + BOOL isNoteToSelf = (IsNoteToSelfEnabled() && [recipientId isEqualToString:self.tsAccountManager.localNumber]); if (isNoteToSelf) { self.nameLabel.attributedText = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.") diff --git a/SignalMessaging/utils/ConversationSearcher.swift b/SignalMessaging/utils/ConversationSearcher.swift index 315d5b5e6..f17a11f8a 100644 --- a/SignalMessaging/utils/ConversationSearcher.swift +++ b/SignalMessaging/utils/ConversationSearcher.swift @@ -241,11 +241,11 @@ public class ConversationSearcher: NSObject { private func conversationIndexingString(recipientId: String) -> String { var result = self.indexingString(recipientId: recipientId) - if let localNumber = tsAccountManager.localNumber() { - if localNumber == recipientId { - let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.") - result += " \(noteToSelfLabel)" - } + if IsNoteToSelfEnabled(), + let localNumber = tsAccountManager.localNumber(), + localNumber == recipientId { + let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.") + result += " \(noteToSelfLabel)" } return result diff --git a/SignalServiceKit/src/Contacts/TSThread.h b/SignalServiceKit/src/Contacts/TSThread.h index 2aa098655..fa4527b12 100644 --- a/SignalServiceKit/src/Contacts/TSThread.h +++ b/SignalServiceKit/src/Contacts/TSThread.h @@ -6,6 +6,8 @@ NS_ASSUME_NONNULL_BEGIN +BOOL IsNoteToSelfEnabled(void); + @class OWSDisappearingMessagesConfiguration; @class TSInteraction; @class TSInvalidIdentityKeyReceivingErrorMessage; diff --git a/SignalServiceKit/src/Contacts/TSThread.m b/SignalServiceKit/src/Contacts/TSThread.m index 26eb0b697..97e95158d 100644 --- a/SignalServiceKit/src/Contacts/TSThread.m +++ b/SignalServiceKit/src/Contacts/TSThread.m @@ -22,6 +22,11 @@ NS_ASSUME_NONNULL_BEGIN +BOOL IsNoteToSelfEnabled(void) +{ + return NO; +} + ConversationColorName const ConversationColorNameCrimson = @"red"; ConversationColorName const ConversationColorNameVermilion = @"orange"; ConversationColorName const ConversationColorNameBurlap = @"brown"; @@ -194,6 +199,9 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa - (BOOL)isNoteToSelf { + if (!IsNoteToSelfEnabled()) { + return NO; + } return (!self.isGroupThread && self.contactIdentifier != nil && [self.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]); } diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index ed4c7cdcc..00b64dd11 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -171,11 +171,12 @@ public class FullTextSearchFinder: NSObject { let recipientId = contactThread.contactIdentifier() var result = recipientIndexer.index(recipientId, transaction: transaction) - if let localNumber = tsAccountManager.storedOrCachedLocalNumber(transaction) { - if localNumber == recipientId { - let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.") - result += " \(noteToSelfLabel)" - } + if IsNoteToSelfEnabled(), + let localNumber = tsAccountManager.storedOrCachedLocalNumber(transaction), + localNumber == recipientId { + + let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.") + result += " \(noteToSelfLabel)" } return result