From 69c49d4a7bf08a0e3aba2c3eac4a79f3fa816590 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 2 Mar 2018 16:33:38 -0500 Subject: [PATCH] Fix profile avatar downloads. --- SignalMessaging/profiles/OWSProfileManager.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index d2383ea5a..024c8d14b 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -912,6 +912,13 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; return; } + // If we're transitioning from (no avatar -> no avatar) or from (same avatar -> same avatar), + // don't bother updating the avatar. + BOOL canSkipAvatarUpdate = ((avatarUrlPath.length == 0 && userProfile.avatarUrlPath.length == 0 + && userProfile.avatarFileName.length == 0) + || (avatarUrlPath.length > 0 && userProfile.avatarUrlPath.length > 0 && + [avatarUrlPath isEqualToString:userProfile.avatarUrlPath] && userProfile.avatarFileName)); + NSString *_Nullable profileName = [self decryptProfileNameData:profileNameEncrypted profileKey:userProfile.profileKey]; @@ -938,7 +945,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; completion:nil]; } - if (avatarUrlPath.length > 0) { + if (avatarUrlPath.length > 0 && !canSkipAvatarUpdate) { [self downloadAvatarForUserProfile:userProfile]; } });