parent
14723f3e7f
commit
4e6816ec5e
|
@ -729,16 +729,15 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
return;
|
||||
}
|
||||
|
||||
[userProfile updateWithProfileName:nil
|
||||
profileKey:profileKey
|
||||
avatarUrlPath:nil
|
||||
avatarFileName:nil
|
||||
dbConnection:self.dbConnection
|
||||
completion:^{
|
||||
[ProfileFetcherJob runWithRecipientId:recipientId
|
||||
networkManager:self.networkManager
|
||||
ignoreThrottling:YES];
|
||||
}];
|
||||
[userProfile clearWithProfileKey:profileKey
|
||||
dbConnection:self.dbConnection
|
||||
completion:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||
[ProfileFetcherJob runWithRecipientId:recipientId
|
||||
networkManager:self.networkManager
|
||||
ignoreThrottling:YES];
|
||||
});
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -911,6 +910,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
OWSUserProfile *userProfile =
|
||||
[OWSUserProfile getOrBuildUserProfileForRecipientId:recipientId dbConnection:self.dbConnection];
|
||||
|
||||
if (!userProfile.profileKey) {
|
||||
return;
|
||||
}
|
||||
|
@ -918,8 +918,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
NSString *_Nullable profileName =
|
||||
[self decryptProfileNameData:profileNameEncrypted profileKey:userProfile.profileKey];
|
||||
|
||||
BOOL isAvatarSame = [self isNullableStringEqual:userProfile.avatarUrlPath toString:avatarUrlPath];
|
||||
|
||||
[userProfile updateWithProfileName:profileName
|
||||
avatarUrlPath:avatarUrlPath
|
||||
avatarFileName:userProfile.avatarFileName // use existing file name if already downloaded
|
||||
|
@ -944,10 +942,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
completion:nil];
|
||||
}
|
||||
|
||||
if (!isAvatarSame) {
|
||||
if (avatarUrlPath) {
|
||||
[self downloadAvatarForUserProfile:userProfile];
|
||||
}
|
||||
if (userProfile.avatarUrlPath.length > 0 && userProfile.avatarFileName.length == 0) {
|
||||
[self downloadAvatarForUserProfile:userProfile];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,13 +41,6 @@ extern NSString *const kLocalProfileUniqueId;
|
|||
|
||||
#pragma mark - Update With... Methods
|
||||
|
||||
- (void)updateWithProfileName:(nullable NSString *)profileName
|
||||
profileKey:(OWSAES256Key *)profileKey
|
||||
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||
avatarFileName:(nullable NSString *)avatarFileName
|
||||
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||
completion:(nullable OWSUserProfileCompletion)completion;
|
||||
|
||||
- (void)updateWithProfileName:(nullable NSString *)profileName
|
||||
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||
avatarFileName:(nullable NSString *)avatarFileName
|
||||
|
|
|
@ -105,7 +105,7 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
|
|||
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||
completion:(nullable OWSUserProfileCompletion)completion
|
||||
{
|
||||
id beforeSnapshot = self.dictionaryValue;
|
||||
NSDictionary *beforeSnapshot = self.dictionaryValue;
|
||||
|
||||
changeBlock(self);
|
||||
|
||||
|
@ -116,12 +116,19 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
|
|||
if (latestInstance) {
|
||||
changeBlock(latestInstance);
|
||||
|
||||
id afterSnapshot = latestInstance.dictionaryValue;
|
||||
NSDictionary *afterSnapshot = latestInstance.dictionaryValue;
|
||||
if ([beforeSnapshot isEqual:afterSnapshot]) {
|
||||
DDLogVerbose(
|
||||
@"%@ Ignoring redundant update in %s: %@", self.logTag, functionName, self.debugDescription);
|
||||
didChange = NO;
|
||||
} else {
|
||||
NSString *_Nullable oldAvatarUrlPath = beforeSnapshot[@"avatarUrlPath"];
|
||||
if (!latestInstance.avatarUrlPath || ![latestInstance.avatarUrlPath isEqual:oldAvatarUrlPath]) {
|
||||
// If the avatarURL changed, the avatarFileName can't be valid.
|
||||
// Clear it.
|
||||
latestInstance.avatarFileName = nil;
|
||||
}
|
||||
|
||||
[latestInstance saveWithTransaction:transaction];
|
||||
}
|
||||
} else {
|
||||
|
@ -198,24 +205,6 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
|
|||
completion:completion];
|
||||
}
|
||||
|
||||
- (void)updateWithProfileName:(nullable NSString *)profileName
|
||||
profileKey:(OWSAES256Key *)profileKey
|
||||
avatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||
avatarFileName:(nullable NSString *)avatarFileName
|
||||
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||
completion:(nullable OWSUserProfileCompletion)completion
|
||||
{
|
||||
[self applyChanges:^(OWSUserProfile *userProfile) {
|
||||
[userProfile setProfileName:[profileName ows_stripped]];
|
||||
[userProfile setProfileKey:profileKey];
|
||||
[userProfile setAvatarUrlPath:avatarUrlPath];
|
||||
[userProfile setAvatarFileName:avatarFileName];
|
||||
}
|
||||
functionName:__PRETTY_FUNCTION__
|
||||
dbConnection:dbConnection
|
||||
completion:completion];
|
||||
}
|
||||
|
||||
- (void)updateWithAvatarUrlPath:(nullable NSString *)avatarUrlPath
|
||||
avatarFileName:(nullable NSString *)avatarFileName
|
||||
dbConnection:(YapDatabaseConnection *)dbConnection
|
||||
|
|
Loading…
Reference in New Issue