Respond to CR.

pull/1/head
Matthew Chen 8 years ago
parent b9b3eb0541
commit 8642a708e7

@ -32,7 +32,7 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
- (OWSAES256Key *)localProfileKey; - (OWSAES256Key *)localProfileKey;
// localUserProfileExists is true if there is _ANY_ local profile. // localUserProfileExists is true if there is _ANY_ local profile.
- (BOOL)localProfileExists; - (BOOL)localProfileExists;
// localUserProfileExists is true if there is a local profile with a name or avatar. // hasLocalProfile is true if there is a local profile with a name or avatar.
- (BOOL)hasLocalProfile; - (BOOL)hasLocalProfile;
- (nullable NSString *)localProfileName; - (nullable NSString *)localProfileName;
- (nullable UIImage *)localProfileAvatarImage; - (nullable UIImage *)localProfileAvatarImage;

@ -54,7 +54,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
@property (atomic, readonly) OWSUserProfile *localUserProfile; @property (atomic, readonly) OWSUserProfile *localUserProfile;
// This property can be accessed on any thread, while synchronized on self. // This property can be accessed on any thread, while synchronized on self.
//@property (atomic, readonly) NSCache<NSString *, UIImage *> *otherUsersProfileAvatarImageCache;
@property (atomic, readonly) NSCache<NSString *, UIImage *> *profileAvatarImageCache; @property (atomic, readonly) NSCache<NSString *, UIImage *> *profileAvatarImageCache;
// This property can be accessed on any thread, while synchronized on self. // This property can be accessed on any thread, while synchronized on self.
@ -595,7 +594,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
__block BOOL result = NO; __block BOOL result = NO;
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
NSNumber *_Nullable oldValue = NSNumber *_Nullable oldValue =
[transaction objectForKey:recipientId inCollection:kOWSProfileManager_UserWhitelistCollection]; [transaction objectForKey:recipientId inCollection:kOWSProfileManager_UserWhitelistCollection];
result = (oldValue && oldValue.boolValue); result = (oldValue && oldValue.boolValue);
@ -661,7 +660,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
NSString *groupIdKey = [groupId hexadecimalString]; NSString *groupIdKey = [groupId hexadecimalString];
__block BOOL result = NO; __block BOOL result = NO;
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
NSNumber *_Nullable oldValue = NSNumber *_Nullable oldValue =
[transaction objectForKey:groupIdKey inCollection:kOWSProfileManager_GroupWhitelistCollection]; [transaction objectForKey:groupIdKey inCollection:kOWSProfileManager_GroupWhitelistCollection];
result = (oldValue && oldValue.boolValue); result = (oldValue && oldValue.boolValue);

@ -20,6 +20,9 @@ extern NSString *const kNSNotificationKey_ProfileGroupId;
extern NSString *const kLocalProfileUniqueId; extern NSString *const kLocalProfileUniqueId;
// This class should be completely thread-safe. // This class should be completely thread-safe.
//
// It is critical for coherency that all DB operations for this
// class should be done on OWSProfileManager's dbConnection.
@interface OWSUserProfile : TSYapDatabaseObject @interface OWSUserProfile : TSYapDatabaseObject
@property (atomic, readonly) NSString *recipientId; @property (atomic, readonly) NSString *recipientId;

@ -37,6 +37,12 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
@implementation OWSUserProfile @implementation OWSUserProfile
+ (NSString *)collection
{
// Legacy class name.
return @"UserProfile";
}
+ (OWSUserProfile *)getOrBuildUserProfileForRecipientId:(NSString *)recipientId + (OWSUserProfile *)getOrBuildUserProfileForRecipientId:(NSString *)recipientId
dbConnection:(YapDatabaseConnection *)dbConnection dbConnection:(YapDatabaseConnection *)dbConnection
{ {
@ -329,13 +335,14 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
return TSYapDatabaseObject.dbReadWriteConnection; return TSYapDatabaseObject.dbReadWriteConnection;
} }
// This should only be used in verbose, developer-only logs.
- (NSString *)debugDescription - (NSString *)debugDescription
{ {
return [NSString stringWithFormat:@"%@ %p %@ %@ %@ %@ %@ %f", return [NSString stringWithFormat:@"%@ %p %@ %zd %@ %@ %@ %f",
self.logTag, self.logTag,
self, self,
self.recipientId, self.recipientId,
self.profileKey.keyData.hexadecimalString, self.profileKey.keyData.length,
self.profileName, self.profileName,
self.avatarUrlPath, self.avatarUrlPath,
self.avatarFileName, self.avatarFileName,

Loading…
Cancel
Save