summaryrefslogtreecommitdiff
path: root/Juick/Views
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-12-30 08:57:15 +0300
committerGravatar Vitaly Takmazov2020-12-30 08:57:15 +0300
commit650fd803616d0e782d02b965c49fa06be65cea79 (patch)
treeb6c6400cd72d86de438415e79a9ed41ae6af7e79 /Juick/Views
parent3d0d75fd56fe5823468318129de4da55e4b27b25 (diff)
Fetch external users
Diffstat (limited to 'Juick/Views')
-rw-r--r--Juick/Views/MessageCell.m22
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];