Use background task while downloading profile avatar.

This commit is contained in:
Matthew Chen 2018-05-31 10:31:53 -04:00
parent 58ee518b26
commit 40729dbdd2
1 changed files with 5 additions and 0 deletions

View File

@ -801,6 +801,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
{
OWSAssert(userProfile);
__block OWSBackgroundTask *backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (userProfile.avatarUrlPath.length < 1) {
OWSFail(@"%@ Malformed avatar URL: %@", self.logTag, userProfile.avatarUrlPath);
@ -884,6 +886,9 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
[localUserProfile updateWithAvatarFileName:fileName dbConnection:self.dbConnection completion:nil];
[self updateProfileAvatarCache:image filename:fileName];
}
OWSAssert(backgroundTask);
backgroundTask = nil;
});
};