diff --git a/SignalMessaging/profiles/OWSProfileManager.swift b/SignalMessaging/profiles/OWSProfileManager.swift index 320533be3f..7f7ef11d01 100644 --- a/SignalMessaging/profiles/OWSProfileManager.swift +++ b/SignalMessaging/profiles/OWSProfileManager.swift @@ -9,7 +9,6 @@ public extension OWSProfileManager { // The main entry point for updating the local profile. It will: // - // * Update local state optimistically. // * Enqueue a service update. // * Attempt that service update. // @@ -302,14 +301,7 @@ extension OWSProfileManager { let promise = firstly { writeProfileAvatarToDisk(attempt: attempt) }.then(on: DispatchQueue.global()) { () -> Promise in - // Optimistically update local profile state. - databaseStorage.write { transaction in - self.updateLocalProfile(with: attempt, - userProfileWriter: userProfileWriter, - transaction: transaction) - } - - Logger.info("Versioned profile update.") + Logger.info("Versioned profile update, avatarUrlPath: \(attempt.avatarUrlPath?.nilIfEmpty != nil), avatarFilename: \(attempt.avatarFilename?.nilIfEmpty != nil)") return updateProfileOnServiceVersioned(attempt: attempt) }.done(on: DispatchQueue.global()) { _ in self.databaseStorage.write { (transaction: SDSAnyWriteTransaction) -> Void in diff --git a/SignalMessaging/profiles/VersionedProfilesImpl.swift b/SignalMessaging/profiles/VersionedProfilesImpl.swift index 34861e3019..122bf29b13 100644 --- a/SignalMessaging/profiles/VersionedProfilesImpl.swift +++ b/SignalMessaging/profiles/VersionedProfilesImpl.swift @@ -43,7 +43,7 @@ public class VersionedProfilesImpl: NSObject, VersionedProfilesSwift { profileAvatarData: Data?, unsavedRotatedProfileKey: OWSAES256Key?) -> Promise { - return DispatchQueue.global().async(.promise) { + firstly(on: .global()) { guard let localUuid = self.tsAccountManager.localUuid else { throw OWSAssertionError("Missing localUuid.") } @@ -54,7 +54,7 @@ public class VersionedProfilesImpl: NSObject, VersionedProfilesSwift { let profileKey: OWSAES256Key = unsavedRotatedProfileKey ?? self.profileManager.localProfileKey() return (localUuid, profileKey) - }.then(on: DispatchQueue.global()) { (localUuid: UUID, profileKey: OWSAES256Key) -> Promise in + }.then(on: .global()) { (localUuid: UUID, profileKey: OWSAES256Key) -> Promise in let localProfileKey = try self.parseProfileKey(profileKey: profileKey) let zkgUuid = try localUuid.asZKGUuid() let commitment = try localProfileKey.getCommitment(uuid: zkgUuid) diff --git a/SignalServiceKit/src/Util/OWSUserProfile.m b/SignalServiceKit/src/Util/OWSUserProfile.m index 4b51f305a9..1b3b4f2c21 100644 --- a/SignalServiceKit/src/Util/OWSUserProfile.m +++ b/SignalServiceKit/src/Util/OWSUserProfile.m @@ -714,8 +714,9 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter) } } + BOOL isUpdatingDatabaseInstance = self != profile; if (shouldReupload && self.tsAccountManager.isPrimaryDevice - && CurrentAppContext().isMainApp) { + && CurrentAppContext().isMainApp && isUpdatingDatabaseInstance) { // shouldReuploadProtectedProfileName has side effects, // so only invoke it if shouldReupload is true. if (OWSUserProfile.shouldReuploadProtectedProfileName) { @@ -744,7 +745,7 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter) @"%d), avatarUrlPathDidChange: %d (%d -> %d), " @"avatarFileNameDidChange: %d (%d -> %d), %@, %@.", profile.address, - profile.address.isLocalAddress, + [OWSUserProfile isLocalProfileAddress:profile.address], profileKeyDidChange, profileKeyBefore != nil, profile.profileKey != nil,