|
|
@ -25,12 +25,18 @@ extension Storage {
|
|
|
|
transaction.setObject(contact, forKey: contact.sessionID, inCollection: Storage.contactCollection)
|
|
|
|
transaction.setObject(contact, forKey: contact.sessionID, inCollection: Storage.contactCollection)
|
|
|
|
transaction.addCompletionQueue(DispatchQueue.main) {
|
|
|
|
transaction.addCompletionQueue(DispatchQueue.main) {
|
|
|
|
// Delete old profile picture if needed
|
|
|
|
// Delete old profile picture if needed
|
|
|
|
if let oldProfilePictureFileName = oldContact?.profilePictureFileName {
|
|
|
|
if let oldProfilePictureFileName = oldContact?.profilePictureFileName,
|
|
|
|
|
|
|
|
oldProfilePictureFileName != contact.profilePictureFileName {
|
|
|
|
let path = OWSUserProfile.profileAvatarFilepath(withFilename: oldProfilePictureFileName)
|
|
|
|
let path = OWSUserProfile.profileAvatarFilepath(withFilename: oldProfilePictureFileName)
|
|
|
|
DispatchQueue.global(qos: .default).async {
|
|
|
|
DispatchQueue.global(qos: .default).async {
|
|
|
|
OWSFileSystem.deleteFileIfExists(path)
|
|
|
|
OWSFileSystem.deleteFileIfExists(path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Download new profile picture if needed
|
|
|
|
|
|
|
|
if contact.profilePictureURL != nil && contact.profilePictureURL != oldContact?.profilePictureURL {
|
|
|
|
|
|
|
|
let profileManager = SSKEnvironment.shared.profileManager
|
|
|
|
|
|
|
|
profileManager.downloadAvatar(forUserProfile: contact)
|
|
|
|
|
|
|
|
}
|
|
|
|
// Post notification
|
|
|
|
// Post notification
|
|
|
|
let notificationCenter = NotificationCenter.default
|
|
|
|
let notificationCenter = NotificationCenter.default
|
|
|
|
notificationCenter.post(name: .contactUpdated, object: contact.sessionID)
|
|
|
|
notificationCenter.post(name: .contactUpdated, object: contact.sessionID)
|
|
|
|