Revert "Making all bk commands in the same thread"

This reverts commit 5f62e3210e.
This commit is contained in:
Daniel García Moreno 2017-08-25 13:39:23 +02:00
parent 5f62e3210e
commit ba3be09fe1

View file

@ -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(())
}