diff --git a/SignalServiceKit/src/Util/OWSUserProfile.m b/SignalServiceKit/src/Util/OWSUserProfile.m index be19474485..d038086ade 100644 --- a/SignalServiceKit/src/Util/OWSUserProfile.m +++ b/SignalServiceKit/src/Util/OWSUserProfile.m @@ -646,6 +646,12 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter) [self anyUpdateWithTransaction:transaction block:^(OWSUserProfile *profile) { + // Load badges so they can be diffed. + [profile.profileBadgeInfo enumerateObjectsUsingBlock:^(OWSUserProfileBadgeInfo * _Nonnull badgeInfo, + NSUInteger idx, + BOOL * _Nonnull stop) { + (void)[badgeInfo fetchBadgeContentWithTransaction:transaction]; + }]; NSArray *avatarKeys = @[ @"avatarFileName", @"avatarUrlPath" ]; // self might be the latest instance, so take a "before" snapshot @@ -665,6 +671,13 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter) profile:profile userProfileWriter:userProfileWriter]; + // Load after updates in case anything changed. + [profile.profileBadgeInfo enumerateObjectsUsingBlock:^(OWSUserProfileBadgeInfo * _Nonnull badgeInfo, + NSUInteger idx, + BOOL * _Nonnull stop) { + (void)[badgeInfo fetchBadgeContentWithTransaction:transaction]; + }]; + profileKeyDidChange = ![NSObject isNullableObject:profileKeyBefore.keyData equalTo:profile.profileKey.keyData]; BOOL givenNameDidChange = ![NSObject isNullableObject:givenNameBefore diff --git a/SignalServiceKit/src/Util/OWSUserProfile.swift b/SignalServiceKit/src/Util/OWSUserProfile.swift index d8381d7948..dd4b75e9c9 100644 --- a/SignalServiceKit/src/Util/OWSUserProfile.swift +++ b/SignalServiceKit/src/Util/OWSUserProfile.swift @@ -54,6 +54,25 @@ public class OWSUserProfileBadgeInfo: NSObject, SDSSwiftSerializable { } return description } + + override public func isEqual(_ object: Any?) -> Bool { + guard let other = object as? OWSUserProfileBadgeInfo else { + return false + } + if badgeId != other.badgeId { + return false + } + if badge != other.badge { + return false + } + if expiration != other.expiration { + return false + } + if isVisible != other.isVisible { + return false + } + return true + } } @objc