Fix profile picture re-uploading

pull/220/head
nielsandriesse 5 years ago
parent 15eee23ad8
commit b8d713b834

@ -259,6 +259,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[[self.syncManager syncLocalContact] retainUntilComplete]; [[self.syncManager syncLocalContact] retainUntilComplete];
} }
*/ */
if (requiresSync) { if (requiresSync) {
[LKSyncMessagesProtocol syncProfile]; [LKSyncMessagesProtocol syncProfile];
} }
@ -278,6 +279,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[[self.syncManager syncLocalContact] retainUntilComplete]; [[self.syncManager syncLocalContact] retainUntilComplete];
} }
*/ */
if (requiresSync) { if (requiresSync) {
[LKSyncMessagesProtocol syncProfile]; [LKSyncMessagesProtocol syncProfile];
} }
@ -327,29 +329,20 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
// * Encrypt it // * Encrypt it
// * Upload it to asset service // * Upload it to asset service
// * Send asset service info to Signal Service // * Send asset service info to Signal Service
if (self.localProfileAvatarImage == avatarImage) { OWSLogVerbose(@"Updating local profile on service with new avatar.");
OWSAssertDebug(userProfile.avatarUrlPath.length > 0); [self writeAvatarToDisk:avatarImage
OWSAssertDebug(userProfile.avatarFileName.length > 0); success:^(NSData *data, NSString *fileName) {
[self uploadAvatarToService:data
OWSLogVerbose(@"Updating local profile on service with unchanged avatar."); success:^(NSString *_Nullable avatarUrlPath) {
// If the avatar hasn't changed, reuse the existing metadata. tryToUpdateService(avatarUrlPath, fileName);
tryToUpdateService(userProfile.avatarUrlPath, userProfile.avatarFileName); }
} else { failure:^(NSError *error) {
OWSLogVerbose(@"Updating local profile on service with new avatar."); failureBlock(error);
[self writeAvatarToDisk:avatarImage }];
success:^(NSData *data, NSString *fileName) { }
[self uploadAvatarToService:data failure:^(NSError *error) {
success:^(NSString *_Nullable avatarUrlPath) { failureBlock(error);
tryToUpdateService(avatarUrlPath, fileName); }];
}
failure:^(NSError *error) {
failureBlock(error);
}];
}
failure:^(NSError *error) {
failureBlock(error);
}];
}
} else if (userProfile.avatarUrlPath) { } else if (userProfile.avatarUrlPath) {
OWSLogVerbose(@"Updating local profile on service with cleared avatar."); OWSLogVerbose(@"Updating local profile on service with cleared avatar.");
[self uploadAvatarToService:nil [self uploadAvatarToService:nil

Loading…
Cancel
Save