|
|
|
@ -136,6 +136,24 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|
|
|
|
failure:failure];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)startObserving
|
|
|
|
|
{
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
selector:@selector(otherUsersProfileDidChange:)
|
|
|
|
|
name:kNSNotificationName_OtherUsersProfileDidChange
|
|
|
|
|
object:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)otherUsersProfileDidChange:(NSNotification *)notification
|
|
|
|
|
{
|
|
|
|
|
OWSAssert([NSThread isMainThread]);
|
|
|
|
|
|
|
|
|
|
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
|
|
|
|
|
OWSAssert(recipientId.length > 0);
|
|
|
|
|
|
|
|
|
|
[self clearAvatarCacheForRecipientId:recipientId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateWithContacts:(NSArray<Contact *> *)contacts
|
|
|
|
|
{
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
@ -165,6 +183,11 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)clearAvatarCacheForRecipientId:(NSString *)recipientId
|
|
|
|
|
{
|
|
|
|
|
[self.avatarCache removeObjectForKey:recipientId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateSignalAccounts
|
|
|
|
|
{
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
@ -423,16 +446,25 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
|
|
|
|
|
return [NSString stringWithFormat:profileNameFormatString, profileName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId
|
|
|
|
|
{
|
|
|
|
|
return [self.profileManager profileNameForRecipientId:recipientId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (nullable NSString *)nameFromSystemContactsForRecipientId:(NSString *)recipientId
|
|
|
|
|
{
|
|
|
|
|
return [self cachedDisplayNameForRecipientId:recipientId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *_Nonnull)displayNameForPhoneIdentifier:(NSString *_Nullable)recipientId
|
|
|
|
|
{
|
|
|
|
|
if (!recipientId) {
|
|
|
|
|
return self.unknownContactName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prefer a saved name from system contacts, if available
|
|
|
|
|
NSString *_Nullable displayName = [self cachedDisplayNameForRecipientId:recipientId];
|
|
|
|
|
NSString *_Nullable displayName = [self nameFromSystemContactsForRecipientId:recipientId];
|
|
|
|
|
|
|
|
|
|
// Else fall back to just using their recipientId
|
|
|
|
|
// Fall back to just using their recipientId
|
|
|
|
|
if (displayName.length < 1) {
|
|
|
|
|
displayName = recipientId;
|
|
|
|
|
}
|
|
|
|
|