Ensure avatar upates right after profile change.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent f6720f9afa
commit bde40a1f9c

@ -2564,11 +2564,7 @@
"DEBUG=1",
"$(inherited)",
);
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = (
"DEBUG=1",
"$(inherited)",
"SSK_BUILDING_FOR_TESTS=1",
);
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = "DEBUG=1 $(inherited) SSK_BUILDING_FOR_TESTS=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
diameter:(NSUInteger)diameter
contactsManager:(OWSContactsManager *)contactsManager
{
// Name for avatar initialis.
// Name for avatar initials.
NSString *_Nullable name = [contactsManager nameFromSystemContactsForRecipientId:signalId];
if (name.length == 0) {
name = [contactsManager profileNameForRecipientId:signalId];

@ -7,6 +7,7 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *const kNSNotificationName_LocalProfileDidChange;
extern NSString *const kNSNotificationName_OtherUsersProfileWillChange;
extern NSString *const kNSNotificationName_OtherUsersProfileDidChange;
extern NSString *const kNSNotificationName_ProfileWhitelistDidChange;
extern NSString *const kNSNotificationKey_ProfileRecipientId;

@ -86,6 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
NSString *const kNSNotificationName_LocalProfileDidChange = @"kNSNotificationName_LocalProfileDidChange";
NSString *const kNSNotificationName_OtherUsersProfileWillChange = @"kNSNotificationName_OtherUsersProfileWillChange";
NSString *const kNSNotificationName_OtherUsersProfileDidChange = @"kNSNotificationName_OtherUsersProfileDidChange";
NSString *const kNSNotificationName_ProfileWhitelistDidChange = @"kNSNotificationName_ProfileWhitelistDidChange";
NSString *const kNSNotificationKey_ProfileRecipientId = @"kNSNotificationKey_ProfileRecipientId";
@ -239,6 +240,12 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
object:nil
userInfo:nil];
} else {
[[NSNotificationCenter defaultCenter]
postNotificationName:kNSNotificationName_OtherUsersProfileWillChange
object:nil
userInfo:@{
kNSNotificationKey_ProfileRecipientId : userProfile.recipientId,
}];
[[NSNotificationCenter defaultCenter]
postNotificationName:kNSNotificationName_OtherUsersProfileDidChange
object:nil

@ -212,10 +212,10 @@ const NSUInteger kAvatarViewDiameter = 52;
name:kNSNotificationName_OtherUsersProfileDidChange
object:nil];
[self updateNameLabel];
[self updateAvatarView];
self.snippetLabel.attributedText = snippetText;
self.timeLabel.attributedText = attributedDate;
self.avatarView.image = nil;
self.separatorInset = UIEdgeInsetsMake(0, self.avatarSize * 1.5f, 0, 0);
@ -229,11 +229,27 @@ const NSUInteger kAvatarViewDiameter = 52;
self.unreadBadge.hidden = YES;
self.unreadLabel.hidden = YES;
}
}
- (void)updateAvatarView
{
OWSContactsManager *contactsManager = self.contactsManager;
if (contactsManager == nil) {
OWSFail(@"%@ contactsManager should not be nil", self.logTag);
self.avatarView.image = nil;
return;
}
TSThread *thread = self.thread;
if (thread == nil) {
OWSFail(@"%@ thread should not be nil", self.logTag);
self.avatarView.image = nil;
return;
}
self.avatarView.image =
[OWSAvatarBuilder buildImageForThread:thread diameter:kAvatarViewDiameter contactsManager:contactsManager];
}
#pragma mark - Date formatting
- (NSAttributedString *)dateAttributedString:(NSDate *)date {
@ -286,6 +302,7 @@ const NSUInteger kAvatarViewDiameter = 52;
}
[self updateNameLabel];
[self updateAvatarView];
}
-(void)updateNameLabel

@ -139,12 +139,12 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
- (void)startObserving
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(otherUsersProfileDidChange:)
name:kNSNotificationName_OtherUsersProfileDidChange
selector:@selector(otherUsersProfileWillChange:)
name:kNSNotificationName_OtherUsersProfileWillChange
object:nil];
}
- (void)otherUsersProfileDidChange:(NSNotification *)notification
- (void)otherUsersProfileWillChange:(NSNotification *)notification
{
OWSAssert([NSThread isMainThread]);

@ -129,6 +129,7 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
name:kNSNotificationName_OtherUsersProfileDidChange
object:nil];
[self updateProfileName];
[self updateAvatar];
if (self.accessoryMessage) {
UILabel *blockedLabel = [[UILabel alloc] init];
@ -141,10 +142,6 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
self.accessoryView = blockedLabel;
}
self.avatarView.image = [[[OWSContactAvatarBuilder alloc] initWithSignalId:recipientId
diameter:kContactTableViewCellAvatarSize
contactsManager:contactsManager] build];
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
[self layoutSubviews];
}
@ -197,7 +194,26 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
return [text copy];
}
- (void)updateAvatar
{
OWSContactsManager *contactsManager = self.contactsManager;
if (contactsManager == nil) {
OWSFail(@"%@ contactsManager should not be nil", self.logTag);
self.avatarView.image = nil;
return;
}
NSString *recipientId = self.recipientId;
if (recipientId.length == 0) {
OWSFail(@"%@ recipientId should not be nil", self.logTag);
self.avatarView.image = nil;
return;
}
self.avatarView.image = [[[OWSContactAvatarBuilder alloc] initWithSignalId:recipientId
diameter:kContactTableViewCellAvatarSize
contactsManager:contactsManager] build];
}
- (void)updateProfileName
{
OWSContactsManager *contactsManager = self.contactsManager;
@ -246,6 +262,7 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
if (recipientId.length > 0 && [self.recipientId isEqualToString:recipientId]) {
[self updateProfileName];
[self updateAvatar];
}
}

@ -171,7 +171,7 @@ NSString *const OWSMessageProcessingJobFinderExtensionGroup = @"OWSMessageProces
{
YapDatabaseView *existingView = [database registeredExtension:OWSMessageProcessingJobFinderExtensionName];
if (existingView) {
OWSFail(@"%@ was already initailized.", OWSMessageProcessingJobFinderExtensionName);
OWSFail(@"%@ was already initialized.", OWSMessageProcessingJobFinderExtensionName);
// already initialized
return;
}

Loading…
Cancel
Save