Fix crash

This commit is contained in:
Niels Andriesse 2021-05-13 14:33:44 +10:00
parent 0bff796ab1
commit 3d35face94
1 changed files with 3 additions and 7 deletions

View File

@ -362,14 +362,10 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
NSData *encryptedAvatarData = [self encryptProfileData:avatarData profileKey:newProfileKey];
OWSAssertDebug(encryptedAvatarData.length > 0);
AnyPromise *promise;
if (SNFeatures.useV2FileServer) {
promise = [SNFileServerAPIV2 upload:encryptedAvatarData];
} else {
promise = [SNFileServerAPI uploadProfilePicture:encryptedAvatarData];
}
AnyPromise *promise = [SNFileServerAPIV2 upload:encryptedAvatarData];
[promise.thenOn(dispatch_get_main_queue(), ^(NSString *downloadURL) {
[promise.thenOn(dispatch_get_main_queue(), ^(uint64_t fileID) {
NSString *downloadURL = [NSString stringWithFormat:@"%@/files/%llu", SNFileServerAPIV2.server, fileID];
[NSUserDefaults.standardUserDefaults setObject:[NSDate new] forKey:@"lastProfilePictureUpload"];
[self.localUserProfile updateWithProfileKey:newProfileKey dbConnection:self.dbConnection completion:^{
successBlock(downloadURL);