Respond to CR.

pull/1/head
Matthew Chen 6 years ago
parent a7909c9c2e
commit 449633e0dc

@ -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" #import "ConversationViewController.h"
@ -497,7 +497,7 @@ typedef enum : NSUInteger {
} }
TSGroupThread *groupThread = (TSGroupThread *)self.thread; TSGroupThread *groupThread = (TSGroupThread *)self.thread;
return ![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber]; return !groupThread.isLocalUserInGroup;
} }
- (void)hideInputIfNeeded - (void)hideInputIfNeeded
@ -1258,8 +1258,7 @@ typedef enum : NSUInteger {
} else { } else {
OWSAssertDebug(self.thread.contactIdentifier); OWSAssertDebug(self.thread.contactIdentifier);
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]; if (self.thread.isNoteToSelf) {
if (isNoteToSelf) {
name = [[NSAttributedString alloc] name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.") initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{ attributes:@{

@ -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" #import "HomeViewCell.h"
@ -517,8 +517,7 @@ NS_ASSUME_NONNULL_BEGIN
name = [[NSAttributedString alloc] initWithString:thread.name]; name = [[NSAttributedString alloc] initWithString:thread.name];
} }
} else { } else {
BOOL isNoteToSelf = [self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]; if (self.thread.threadRecord.isNoteToSelf) {
if (isNoteToSelf) {
name = [[NSAttributedString alloc] name = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.") initWithString:NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.")
attributes:@{ attributes:@{

@ -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" #import "OWSConversationSettingsViewController.h"
@ -310,8 +310,7 @@ const CGFloat kIconViewLength = 24;
OWSTableContents *contents = [OWSTableContents new]; OWSTableContents *contents = [OWSTableContents new];
contents.title = NSLocalizedString(@"CONVERSATION_SETTINGS", @"title for conversation settings screen"); contents.title = NSLocalizedString(@"CONVERSATION_SETTINGS", @"title for conversation settings screen");
BOOL isNoteToSelf = (!self.thread.isGroupThread && BOOL isNoteToSelf = self.thread.isNoteToSelf;
[self.thread.contactIdentifier isEqualToString:self.tsAccountManager.localNumber]);
__weak OWSConversationSettingsViewController *weakSelf = self; __weak OWSConversationSettingsViewController *weakSelf = self;
@ -1085,8 +1084,7 @@ const CGFloat kIconViewLength = 24;
{ {
if (self.isGroupThread) { if (self.isGroupThread) {
TSGroupThread *groupThread = (TSGroupThread *)self.thread; TSGroupThread *groupThread = (TSGroupThread *)self.thread;
BOOL inGroup = [groupThread.groupModel.groupMemberIds containsObject:TSAccountManager.localNumber]; return !groupThread.isLocalUserInGroup;
return !inGroup;
} }
return NO; return NO;

@ -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" #import "TSConstants.h"
@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, OWSRegistrationState) {
- (nullable NSString *)localNumber; - (nullable NSString *)localNumber;
// A variant of localNumber that never opens a "sneaky" transaction. // 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, * Symmetric key that's used to encrypt message payloads from the server,

@ -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" #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 return [transaction stringForKey:TSAccountManager_RegisteredNumberKey
inCollection:TSAccountManager_UserAccountCollection]; inCollection:TSAccountManager_UserAccountCollection];
} }

@ -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" #import "TSYapDatabaseObject.h"
@ -68,6 +68,8 @@ extern ConversationColorName const kConversationColorName_Default;
*/ */
@property (nonatomic, readonly) NSArray<NSString *> *recipientIdentifiers; @property (nonatomic, readonly) NSArray<NSString *> *recipientIdentifiers;
- (BOOL)isNoteToSelf;
#pragma mark Interactions #pragma mark Interactions
/** /**

@ -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" #import "TSThread.h"
@ -7,6 +7,8 @@
#import "OWSDisappearingMessagesConfiguration.h" #import "OWSDisappearingMessagesConfiguration.h"
#import "OWSPrimaryStorage.h" #import "OWSPrimaryStorage.h"
#import "OWSReadTracking.h" #import "OWSReadTracking.h"
#import "SSKEnvironment.h"
#import "TSAccountManager.h"
#import "TSDatabaseView.h" #import "TSDatabaseView.h"
#import "TSIncomingMessage.h" #import "TSIncomingMessage.h"
#import "TSInfoMessage.h" #import "TSInfoMessage.h"
@ -55,6 +57,17 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
@implementation TSThread @implementation TSThread
#pragma mark - Dependencies
- (TSAccountManager *)tsAccountManager
{
OWSAssertDebug(SSKEnvironment.shared.tsAccountManager);
return SSKEnvironment.shared.tsAccountManager;
}
#pragma mark -
+ (NSString *)collection { + (NSString *)collection {
return @"TSThread"; 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 { - (BOOL)isGroupThread {
OWSAbstractMethod(); OWSAbstractMethod();
@ -211,7 +230,7 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
return NO; return NO;
} }
#pragma mark Interactions #pragma mark - Interactions
/** /**
* Iterate over this thread's 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: - (OWSDisappearingMessagesConfiguration *)disappearingMessagesConfigurationWithTransaction:
(YapDatabaseReadTransaction *)transaction (YapDatabaseReadTransaction *)transaction

@ -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" #import "OWSMessageManager.h"
@ -511,7 +511,7 @@ NS_ASSUME_NONNULL_BEGIN
if (groupThread) { if (groupThread) {
if (dataMessage.group.type != SSKProtoGroupContextTypeUpdate) { if (dataMessage.group.type != SSKProtoGroupContextTypeUpdate) {
if (![groupThread.groupModel.groupMemberIds containsObject:self.tsAccountManager.localNumber]) { if (!groupThread.isLocalUserInGroup) {
OWSLogInfo(@"Ignoring messages for left group."); OWSLogInfo(@"Ignoring messages for left group.");
return; return;
} }
@ -705,7 +705,7 @@ NS_ASSUME_NONNULL_BEGIN
if (typingMessage.hasGroupID) { if (typingMessage.hasGroupID) {
TSGroupThread *groupThread = [TSGroupThread threadWithGroupId:typingMessage.groupID transaction:transaction]; 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."); OWSLogInfo(@"Ignoring messages for left group.");
return; return;
} }
@ -1135,8 +1135,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
// Ensure we are in the group. // Ensure we are in the group.
NSString *localNumber = self.tsAccountManager.localNumber; if (!gThread.isLocalUserInGroup) {
if (![gThread.groupModel.groupMemberIds containsObject:localNumber]) {
OWSLogWarn(@"Ignoring 'Request Group Info' message for group we no longer belong to."); OWSLogWarn(@"Ignoring 'Request Group Info' message for group we no longer belong to.");
return; return;
} }

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -192,7 +192,7 @@ public class FullTextSearchFinder: NSObject {
var result = "\(recipientId) \(nationalNumber) \(displayName)" var result = "\(recipientId) \(nationalNumber) \(displayName)"
if let localNumber = tsAccountManager.storedLocalNumber(transaction) { if let localNumber = tsAccountManager.storedOrCachedLocalNumber(transaction) {
if localNumber == recipientId { if localNumber == recipientId {
let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.") let noteToSelfLabel = NSLocalizedString("NOTE_TO_SELF", comment: "Label for 1:1 conversation with yourself.")
result += " \(noteToSelfLabel)" result += " \(noteToSelfLabel)"

Loading…
Cancel
Save