From eb7c589ae646ee2659f2b2cc0a2367422e642210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Sun, 24 Dec 2017 17:00:39 +0100 Subject: [PATCH] Member username and avatar from API call, not sync Fix #36 --- fractal-gtk/src/widgets/member.rs | 14 +++++++++++--- fractal-gtk/src/widgets/message.rs | 5 ++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fractal-gtk/src/widgets/member.rs b/fractal-gtk/src/widgets/member.rs index 5563c24d..d75dc4ff 100644 --- a/fractal-gtk/src/widgets/member.rs +++ b/fractal-gtk/src/widgets/member.rs @@ -46,7 +46,7 @@ impl<'a> MemberBox<'a> { let avatar = widgets::Avatar::avatar_new(Some(globals::USERLIST_ICON_SIZE)); avatar.default(String::from("avatar-default-symbolic"), Some(globals::USERLIST_ICON_SIZE)); - get_member_avatar(backend.clone(), avatar.clone(), Some(self.member.clone()), globals::USERLIST_ICON_SIZE, 10); + get_member_info(backend.clone(), avatar.clone(), username.clone(), self.member.uid.clone(), globals::USERLIST_ICON_SIZE, 10); avatar.set_margin_start(5); w.add(&avatar); @@ -58,7 +58,11 @@ impl<'a> MemberBox<'a> { } } -pub fn get_member_avatar(backend: Sender, img: widgets::Avatar, m: Option, size: i32, tries: i32) { +#[allow(dead_code)] +pub fn get_member_avatar(backend: Sender, + img: widgets::Avatar, + m: Option, + size: i32, tries: i32) { if tries <= 0 { return; } @@ -83,7 +87,11 @@ pub fn get_member_avatar(backend: Sender, img: widgets::Avatar, m: Op -pub fn get_member_info(backend: Sender, img: widgets::Avatar, username: gtk::Label, sender: String, size: i32, tries: i32) { +pub fn get_member_info(backend: Sender, + img: widgets::Avatar, + username: gtk::Label, + sender: String, + size: i32, tries: i32) { let (tx, rx): (Sender<(String, String)>, Receiver<(String, String)>) = channel(); backend.send(BKCommand::GetUserInfoAsync(sender.clone(), tx)).unwrap(); gtk::timeout_add(100, move || match rx.try_recv() { diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs index 671e4823..f5aa0683 100644 --- a/fractal-gtk/src/widgets/message.rs +++ b/fractal-gtk/src/widgets/message.rs @@ -23,7 +23,6 @@ use app::AppOp; use globals; use widgets; use widgets::AvatarExt; -use widgets::member::get_member_avatar; use widgets::member::get_member_info; // Room Message item @@ -137,11 +136,11 @@ impl<'a> MessageBox<'a> { match m { Some(member) => { self.username.set_markup(&format!("{}", member.get_alias().unwrap_or_default())); - get_member_avatar(backend.clone(), avatar.clone(), m.cloned(), 40, 10); + get_member_info(backend.clone(), avatar.clone(), self.username.clone(), sender.clone(), globals::MSG_ICON_SIZE, 10); } None => { self.username.set_markup(&format!("{} @@", sender)); - get_member_info(backend.clone(), avatar.clone(), self.username.clone(), sender.clone(), 40, 10); + get_member_info(backend.clone(), avatar.clone(), self.username.clone(), sender.clone(), globals::MSG_ICON_SIZE, 10); } };