diff --git a/src/backend.rs b/src/backend.rs index 98b1a747..1418517f 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -373,14 +373,16 @@ impl Backend { let userid = self.data.lock().unwrap().user_id.clone(); let tx = self.tx.clone(); - match get_user_avatar(&baseu, &userid) { - Ok(fname) => { - tx.send(BKResponse::Avatar(fname)).unwrap(); - }, - Err(err) => { - tx.send(BKResponse::AvatarError(err)).unwrap(); + thread::spawn(move || { + match get_user_avatar(&baseu, &userid) { + Ok(fname) => { + tx.send(BKResponse::Avatar(fname)).unwrap(); + }, + Err(err) => { + tx.send(BKResponse::AvatarError(err)).unwrap(); + } } - }; + }); Ok(()) } @@ -562,14 +564,16 @@ impl Backend { let baseu = self.get_base_url()?; let tx = self.tx.clone(); - match thumb!(&baseu, &avatar_url) { - Ok(fname) => { - tx.send(BKResponse::RoomMemberAvatar(memberid, fname)).unwrap(); - }, - Err(err) => { - tx.send(BKResponse::RoomMemberAvatarError(err)).unwrap(); + thread::spawn(move || { + match thumb!(&baseu, &avatar_url) { + Ok(fname) => { + tx.send(BKResponse::RoomMemberAvatar(memberid, fname)).unwrap(); + }, + Err(err) => { + tx.send(BKResponse::RoomMemberAvatarError(err)).unwrap(); + } } - } + }); Ok(()) } @@ -584,8 +588,10 @@ impl Backend { let base = self.get_base_url()?; let u = url.clone(); - let fname = thumb!(&base, &u)?; - tx.send(fname).unwrap(); + thread::spawn(move || { + let fname = thumb!(&base, &u).unwrap(); + tx.send(fname).unwrap(); + }); Ok(()) } @@ -594,10 +600,12 @@ impl Backend { let baseu = self.get_base_url()?; let u = String::from(uid); - match get_user_avatar(&baseu, &u) { - Ok(fname) => { tx.send(fname).unwrap(); }, - Err(_) => { tx.send(String::from("")).unwrap(); } - }; + thread::spawn(move || { + match get_user_avatar(&baseu, &u) { + Ok(fname) => { tx.send(fname).unwrap(); }, + Err(_) => { tx.send(String::from("")).unwrap(); } + }; + }); Ok(()) }