summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/Model/Chat.h1
-rw-r--r--Juick/Model/User.h1
-rw-r--r--Juick/Views/BubbleMessageCell.m2
-rw-r--r--Juick/Views/ConversationCell.m2
-rw-r--r--Juick/Views/MessageCell.m2
5 files changed, 5 insertions, 3 deletions
diff --git a/Juick/Model/Chat.h b/Juick/Model/Chat.h
index a472389..1e80bdf 100644
--- a/Juick/Model/Chat.h
+++ b/Juick/Model/Chat.h
@@ -13,6 +13,7 @@
@property NSNumber *uid;
@property NSString *uname;
+@property NSString *avatar;
@property NSNumber *unreadCount;
@property NSDate *lastMessageTimestamp;
@property NSString *lastMessageText;
diff --git a/Juick/Model/User.h b/Juick/Model/User.h
index 2710e4a..8120dec 100644
--- a/Juick/Model/User.h
+++ b/Juick/Model/User.h
@@ -11,6 +11,7 @@
@interface User : NSObject
@property (nonatomic, strong) NSString *uname;
@property (nonatomic, strong) NSString *uid;
+@property (nonatomic, strong) NSString *avatar;
+ (void) get:(NSString *)name callback:(void(^)(User *))callback;
diff --git a/Juick/Views/BubbleMessageCell.m b/Juick/Views/BubbleMessageCell.m
index 87b482c..70746cf 100644
--- a/Juick/Views/BubbleMessageCell.m
+++ b/Juick/Views/BubbleMessageCell.m
@@ -31,7 +31,7 @@
self.message.text = message.text;
self.unreadMarker.text = @"";
__weak UIImageView *weakAvatar = self.avatarView;
- [self.avatarView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [message.user.uid intValue]]]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
+ [self.avatarView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:message.user.avatar]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
[UIView transitionWithView:weakAvatar
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
diff --git a/Juick/Views/ConversationCell.m b/Juick/Views/ConversationCell.m
index ff5ec2f..4a0be13 100644
--- a/Juick/Views/ConversationCell.m
+++ b/Juick/Views/ConversationCell.m
@@ -22,7 +22,7 @@
self.lastMessage.text = chat.lastMessageText;
self.unreadMarker.hidden = chat.unreadCount > 0;
__weak UIImageView *weakAvatar = self.avatar;
- [self.avatar setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [chat.uid intValue]]]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
+ [self.avatar setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:chat.avatar]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
[UIView transitionWithView:weakAvatar
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index 4637f80..b82d0a1 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -32,7 +32,7 @@
self.message = msg;
self.avatar.image = nil;
__weak UIImageView *weakAvatar = self.avatar;
- [self.avatar setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.user.uid intValue]]]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
+ [self.avatar setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:msg.user.avatar]] placeholderImage:nil success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull image) {
[UIView transitionWithView:weakAvatar
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve