Skip to content

Commit

Permalink
Fix regression resulting in rendering system contact avatars for the …
Browse files Browse the repository at this point in the history
…local user
  • Loading branch information
Imperiopolis committed Dec 8, 2021
1 parent 1f3ef43 commit 5917973
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions SignalMessaging/contacts/ContactsManagerCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,24 @@ public class ContactsMaps: NSObject {
}

fileprivate static func phoneNumbers(forContact contact: Contact, localNumber: String?) -> [String] {
return contact.parsedPhoneNumbers.compactMap { phoneNumber in
let phoneNumbers: [String] = contact.parsedPhoneNumbers.compactMap { phoneNumber in
guard let phoneNumberE164 = phoneNumber.toE164().nilIfEmpty else {
return nil
}

return phoneNumberE164
}

if let localNumber = localNumber, phoneNumbers.contains(localNumber) {
// Ignore any system contact records for the local contact.
// For the local user we never want to show the avatar /
// name that you have entered for yourself in your system
// contacts. Instead, we always want to display your profile
// name and avatar.
let isLocalContact = phoneNumberE164 == localNumber
guard !isLocalContact else {
return nil
}

return phoneNumberE164
return []
}

return phoneNumbers
}

@objc
Expand Down
5 changes: 5 additions & 0 deletions SignalMessaging/contacts/OWSContactsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ extension OWSContactsManager {
return nil
}

guard !address.isLocalAddress else {
// Never use system contact or synced image data for the local user
return nil
}

if let phoneNumber = self.phoneNumber(for: address, transaction: transaction),
let contact = contactsManagerCache.contact(forPhoneNumber: phoneNumber, transaction: transaction),
let cnContactId = contact.cnContactId,
Expand Down

0 comments on commit 5917973

Please sign in to comment.