Respond to CR.

This commit is contained in:
Matthew Chen 2019-01-04 09:19:41 -05:00
parent a7909c9c2e
commit 449633e0dc
9 changed files with 50 additions and 28 deletions

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "ConversationViewController.h"
@ -497,7 +497,7 @@ typedef enum : NSUInteger {
}
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
return ![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber];
return !groupThread.isLocalUserInGroup;
}
- (void)hideInputIfNeeded
@ -1258,8 +1258,7 @@ typedef enum : NSUInteger {
} else {
OWSAssertDebug(self.thread.contactIdentifier);
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber];
if (isNoteToSelf) {
if (self.thread.isNoteToSelf) {
name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "HomeViewCell.h"
@ -517,8 +517,7 @@ NS_ASSUME_NONNULL_BEGIN
name = [[NSAttributedString alloc] initWithString:thread.name];
}
} else {
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber];
if (isNoteToSelf) {
if (self.thread.threadRecord.isNoteToSelf) {
name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSConversationSettingsViewController.h"
@ -310,8 +310,7 @@ 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]);
BOOL isNoteToSelf = self.thread.isNoteToSelf;
__weak OWSConversationSettingsViewController *weakSelf = self;
@ -1085,8 +1084,7 @@ const CGFloat kIconViewLength = 24;
{
if (self.isGroupThread) {
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
BOOL inGroup = [groupThread.groupModel.groupMemberIds containsObject:TSAccountManager.localNumber];
return !inGroup;
return !groupThread.isLocalUserInGroup;
}
return NO;

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "TSConstants.h"
@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, OWSRegistrationState) {
- (nullable NSString *)localNumber;
// A variant of localNumber that never opens a "sneaky" transaction.
- (nullable NSString *)storedLocalNumber:(YapDatabaseReadTransaction *)transaction;
- (nullable NSString *)storedOrCachedLocalNumber:(YapDatabaseReadTransaction *)transaction;
/**
* Symmetric key that's used to encrypt message payloads from the server,

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "TSAccountManager.h"
@ -220,8 +220,14 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
}
}
- (nullable NSString *)storedLocalNumber:(YapDatabaseReadTransaction *)transaction
- (nullable NSString *)storedOrCachedLocalNumber:(YapDatabaseReadTransaction *)transaction
{
@synchronized(self) {
if (self.cachedLocalNumber) {
return self.cachedLocalNumber;
}
}
return [transaction stringForKey:TSAccountManager_RegisteredNumberKey
inCollection:TSAccountManager_UserAccountCollection];
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "TSYapDatabaseObject.h"
@ -68,6 +68,8 @@ extern ConversationColorName const kConversationColorName_Default;
*/
@property (nonatomic, readonly) NSArray<NSString *> *recipientIdentifiers;
- (BOOL)isNoteToSelf;
#pragma mark Interactions
/**

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "TSThread.h"
@ -7,6 +7,8 @@
#import "OWSDisappearingMessagesConfiguration.h"
#import "OWSPrimaryStorage.h"
#import "OWSReadTracking.h"
#import "SSKEnvironment.h"
#import "TSAccountManager.h"
#import "TSDatabaseView.h"
#import "TSIncomingMessage.h"
#import "TSInfoMessage.h"
@ -55,6 +57,17 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
@implementation TSThread
#pragma mark - Dependencies
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
+ (NSString *)collection {
return @"TSThread";
}
@ -179,7 +192,13 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
}
}
#pragma mark To be subclassed.
- (BOOL)isNoteToSelf
{
return (!self.isGroupThread && self.contactIdentifier != nil &&
[self.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]);
}
#pragma mark - To be subclassed.
- (BOOL)isGroupThread {
OWSAbstractMethod();
@ -211,7 +230,7 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
return NO;
}
#pragma mark Interactions
#pragma mark - Interactions
/**
* Iterate over this thread's interactions
@ -405,7 +424,7 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
}
}
#pragma mark Disappearing Messages
#pragma mark - Disappearing Messages
- (OWSDisappearingMessagesConfiguration *)disappearingMessagesConfigurationWithTransaction:
(YapDatabaseReadTransaction *)transaction

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageManager.h"
@ -511,7 +511,7 @@ NS_ASSUME_NONNULL_BEGIN
if (groupThread) {
if (dataMessage.group.type != SSKProtoGroupContextTypeUpdate) {
if (![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber]) {
if (!groupThread.isLocalUserInGroup) {
OWSLogInfo(@"Ignoring messages for left group.");
return;
}
@ -705,7 +705,7 @@ NS_ASSUME_NONNULL_BEGIN
if (typingMessage.hasGroupID) {
TSGroupThread *groupThread = [TSGroupThread threadWithGroupId:typingMessage.groupID transaction:transaction];
if (![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber]) {
if (!groupThread.isLocalUserInGroup) {
OWSLogInfo(@"Ignoring messages for left group.");
return;
}
@ -1135,8 +1135,7 @@ NS_ASSUME_NONNULL_BEGIN
}
// Ensure we are in the group.
NSString *localNumber = self.tsAccountManager.localNumber;
if (![gThread.groupModel.groupMemberIds containsObject:localNumber]) {
if (!gThread.isLocalUserInGroup) {
OWSLogWarn(@"Ignoring 'Request Group Info' message for group we no longer belong to.");
return;
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -192,7 +192,7 @@ public class FullTextSearchFinder: NSObject {
var result = "\(recipientId) \(nationalNumber) \(displayName)"
if let localNumber = tsAccountManager.storedLocalNumber(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)"