diff options
Diffstat (limited to 'Juick/Views')
-rw-r--r-- | Juick/Views/MessageCell.m | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index f02aa48..122f7d9 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -15,6 +15,7 @@ @property(nonatomic, readonly) NSMutableParagraphStyle *quoteStyle; @property(nonatomic, readonly) UIFont *boldFont; @property(nonatomic, readonly) UIFont *italicFont; +- (void) updateAvatarWithUrl:(NSString *)avatarUrl; @end @implementation MessageCell @@ -46,18 +47,29 @@ const NSString *unreadMarker = @"●"; _italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0]; } -- (void) configureWithMessage:(Message *)msg selectable:(BOOL)selectable { +- (void) updateAvatarWithUrl:(NSString *)avatarUrl { self.avatar.image = nil; __weak UIImageView *weakAvatar = self.avatar; - [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.user.avatar] callback:^(NSData *data) { + [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:avatarUrl] callback:^(NSData *data) { [UIView transitionWithView:weakAvatar duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ - weakAvatar.image = [UIImage imageWithData:data]; - } - completion:nil]; + weakAvatar.image = [UIImage imageWithData:data]; + } completion:nil]; }]; +} + +- (void) configureWithMessage:(Message *)msg selectable:(BOOL)selectable { + [self updateAvatarWithUrl:msg.user.avatar]; + if (!msg.user.uid) { + __weak UILabel *title = self.title; + [[AppDelegate shared].api getUserByUri:msg.user.uri callback:^(User *user) { + title.text = user.uname; + NSString *avatarUrl = user.avatar ? user.avatar : [API defaultAvatarUrl]; + [self updateAvatarWithUrl:avatarUrl]; + }]; + } if ([msg.attach length] > 0) { CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale]; CGFloat imageWidth = [msg.attachment.small.width floatValue] / [[UIScreen mainScreen] scale]; |