From c0cb7df10ad9d499456d5e3c96cf85d4b42cdeca Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 11 Dec 2018 14:42:07 -0700 Subject: [PATCH] rename hasEverHadMessage -> shouldThreadBeVisible --- SignalMessaging/utils/ThreadUtil.m | 2 +- SignalServiceKit/src/Contacts/TSThread.h | 2 +- SignalServiceKit/src/Contacts/TSThread.m | 13 +++++++++++-- .../src/Storage/FullTextSearchFinder.swift | 2 +- SignalServiceKit/src/Storage/TSDatabaseView.m | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index b6d562279..068532fa1 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -806,7 +806,7 @@ NS_ASSUME_NONNULL_BEGIN if ([OWSProfileManager.sharedManager isThreadInProfileWhitelist:thread]) { return NO; } - if (!thread.hasEverHadMessage) { + if (!thread.shouldThreadBeVisible) { [OWSProfileManager.sharedManager addThreadToProfileWhitelist:thread]; return YES; } else { diff --git a/SignalServiceKit/src/Contacts/TSThread.h b/SignalServiceKit/src/Contacts/TSThread.h index 0bdc7c106..1b0228c0f 100644 --- a/SignalServiceKit/src/Contacts/TSThread.h +++ b/SignalServiceKit/src/Contacts/TSThread.h @@ -33,7 +33,7 @@ extern ConversationColorName const kConversationColorName_Default; @interface TSThread : TSYapDatabaseObject // YES IFF this thread has ever had a message. -@property (nonatomic) BOOL hasEverHadMessage; +@property (nonatomic) BOOL shouldThreadBeVisible; /** * Whether the object is a group thread or not. diff --git a/SignalServiceKit/src/Contacts/TSThread.m b/SignalServiceKit/src/Contacts/TSThread.m index 4d046f132..7406e9d73 100644 --- a/SignalServiceKit/src/Contacts/TSThread.m +++ b/SignalServiceKit/src/Contacts/TSThread.m @@ -82,7 +82,16 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa if (!self) { return self; } - + + // renamed `hasEverHadMessage` -> `shouldThreadBeVisible` + if (!_shouldThreadBeVisible) { + NSNumber *legacy_hasEverHadMessage = [coder decodeObjectForKey:@"hasEverHadMessage"]; + + if (legacy_hasEverHadMessage != nil) { + _shouldThreadBeVisible = legacy_hasEverHadMessage.boolValue; + } + } + if (_conversationColorName.length == 0) { NSString *_Nullable colorSeed = self.contactIdentifier; if (colorSeed.length > 0) { @@ -390,7 +399,7 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa return; } - self.hasEverHadMessage = YES; + self.shouldThreadBeVisible = YES; NSDate *lastMessageDate = [lastMessage dateForSorting]; if (!_lastMessageDate || [lastMessageDate timeIntervalSinceDate:self.lastMessageDate] > 0) { diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index 53e3e7147..10d0fa9a3 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -204,7 +204,7 @@ public class FullTextSearchFinder: NSObject { if let groupThread = object as? TSGroupThread { return self.groupThreadIndexer.index(groupThread, transaction: transaction) } else if let contactThread = object as? TSContactThread { - guard contactThread.hasEverHadMessage else { + guard contactThread.shouldThreadBeVisible else { // If we've never sent/received a message in a TSContactThread, // then we want it to appear in the "Other Contacts" section rather // than in the "Conversations" section. diff --git a/SignalServiceKit/src/Storage/TSDatabaseView.m b/SignalServiceKit/src/Storage/TSDatabaseView.m index ade284d92..e309b2365 100644 --- a/SignalServiceKit/src/Storage/TSDatabaseView.m +++ b/SignalServiceKit/src/Storage/TSDatabaseView.m @@ -204,7 +204,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" if (thread.isGroupThread) { // Do nothing; we never hide group threads. - } else if (thread.hasEverHadMessage) { + } else if (thread.shouldThreadBeVisible) { // Do nothing; we never hide threads that have ever had a message. } else { YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSMessageDatabaseViewExtensionName];