Merge branch 'nt/profile-share-fix'

This commit is contained in:
Nora Trapp 2019-08-09 12:59:27 -07:00
commit 503b03680d
4 changed files with 13 additions and 12 deletions

View File

@ -2979,7 +2979,7 @@ typedef enum : NSUInteger {
OWSLogVerbose(@"Sending contact share.");
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelist:self.thread];
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
[self.databaseStorage
asyncWriteWithBlock:^(SDSAnyWriteTransaction *transaction) {
@ -3587,7 +3587,7 @@ typedef enum : NSUInteger {
}
}
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelist:self.thread];
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
__block TSOutgoingMessage *message;
[self.databaseStorage uiReadWithBlock:^(SDSAnyReadTransaction *_Nonnull transaction) {
@ -4176,7 +4176,7 @@ typedef enum : NSUInteger {
//
// We convert large text messages to attachments
// which are presented as normal text messages.
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelist:self.thread];
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
__block TSOutgoingMessage *message;
[self.databaseStorage uiReadWithBlock:^(SDSAnyReadTransaction *transaction) {
@ -5155,7 +5155,7 @@ typedef enum : NSUInteger {
{
OWSAssertIsOnMainThread();
[ThreadUtil addThreadToProfileWhitelist:self.thread];
[self.profileManager addThreadToProfileWhitelist:self.thread];
[self dismissMessageRequestView];
}

View File

@ -276,7 +276,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
didApproveAttachments:(NSArray<SignalAttachment *> *_Nonnull)attachments
messageText:(NSString *_Nullable)messageText
{
[ThreadUtil addThreadToProfileWhitelist:self.thread];
[ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
[self
tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
@ -323,7 +323,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
{
OWSAssertDebug(messageText.length > 0);
[ThreadUtil addThreadToProfileWhitelist:self.thread];
[ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
@ -363,7 +363,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
{
OWSLogInfo(@"");
[ThreadUtil addThreadToProfileWhitelist:self.thread];
[ThreadUtil addThreadToProfileWhitelistIfEmptyThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
// TODO - in line with QuotedReply and other message attachments, saving should happen as part of sending

View File

@ -118,11 +118,11 @@ NS_ASSUME_NONNULL_BEGIN
transaction:(SDSAnyReadTransaction *)transaction;
// This method should be called right _before_ we send a message to a thread,
// since we want to auto-add any threads the local user has interacted with
// to the profile whitelist.
// since we want to auto-add any thread to the profile whitelist that was
// initiated by the local user.
//
// Returns YES IFF the thread was just added to the profile whitelist.
+ (BOOL)addThreadToProfileWhitelist:(TSThread *)thread;
+ (BOOL)addThreadToProfileWhitelistIfEmptyThread:(TSThread *)thread;
#pragma mark - Delete Content

View File

@ -734,15 +734,16 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
return @(position);
}
+ (BOOL)addThreadToProfileWhitelist:(TSThread *)thread
+ (BOOL)addThreadToProfileWhitelistIfEmptyThread:(TSThread *)thread
{
OWSAssertDebug(thread);
if ([OWSProfileManager.sharedManager isThreadInProfileWhitelist:thread]) {
if ([OWSProfileManager.sharedManager isThreadInProfileWhitelist:thread] || thread.shouldThreadBeVisible) {
return NO;
}
[OWSProfileManager.sharedManager addThreadToProfileWhitelist:thread];
return YES;
}