Commit bff4277e authored by Daniel García Moreno's avatar Daniel García Moreno

Move internal commands to a new loop

This patch removes the use of the backend loop for interface events.
parent 67ff0360
Pipeline #1715 passed with stage
in 37 minutes and 45 seconds
......@@ -228,12 +228,6 @@ impl Backend {
}
// Internal commands
Ok(BKCommand::SpreadResponse(resp)) => {
tx.send(resp).unwrap();
}
Ok(BKCommand::NotifyClicked(message)) => {
tx.send(BKResponse::NotificationClicked(message)).unwrap();
}
Ok(BKCommand::ShutDown) => {
return false;
}
......
......@@ -45,9 +45,7 @@ pub enum BKCommand {
AttachFile(String, String),
AttachImage(String, Vec<u8>),
Search(String, Option<String>),
NotifyClicked(Message),
NewRoom(String, RoomType),
SpreadResponse(BKResponse),
}
#[derive(Debug)]
......@@ -80,9 +78,7 @@ pub enum BKResponse {
Media(String),
AttachedFile(Message),
SearchEnd,
NotificationClicked(Message),
NewRoom(Room),
RoomSelected(Room),
//errors
UserNameError(Error),
......
......@@ -501,9 +501,9 @@ impl AppOp {
container.add(&self.roomlist.widget());
self.roomlist.set_selected(selected_room);
let bk = self.backend.clone();
let bk = self.internal.clone();
self.roomlist.connect(move |room| {
bk.send(BKCommand::SpreadResponse(BKResponse::RoomSelected(room))).unwrap();
bk.send(InternalCommand::SelectRoom(room)).unwrap();
});
let mut godef = def;
......@@ -1018,7 +1018,7 @@ impl AppOp {
let (tx, rx): (Sender<(String, String)>, Receiver<(String, String)>) = channel();
self.backend.send(BKCommand::GetUserInfoAsync(msg.sender.clone(), tx)).unwrap();
let bk = self.backend.clone();
let bk = self.internal.clone();
let m = msg.clone();
gtk::timeout_add(50, move || match rx.try_recv() {
Err(TryRecvError::Empty) => gtk::Continue(true),
......@@ -1042,7 +1042,7 @@ impl AppOp {
n.wait_for_action({|action|
match action {
"default" => {
bk.send(BKCommand::NotifyClicked(m)).unwrap();
bk.send(InternalCommand::NotifyClicked(m)).unwrap();
},
_ => ()
}
......@@ -2046,9 +2046,6 @@ fn backend_loop(op: Arc<Mutex<AppOp>>, rx: Receiver<BKResponse>) {
println!("SYNC");
op.lock().unwrap().synced(Some(since));
}
Ok(BKResponse::RoomSelected(room)) => {
op.lock().unwrap().set_active_room_by_id(room.id.clone());
}
Ok(BKResponse::Rooms(rooms, default)) => {
op.lock().unwrap().set_rooms(rooms, default);
}
......@@ -2113,9 +2110,6 @@ fn backend_loop(op: Arc<Mutex<AppOp>>, rx: Receiver<BKResponse>) {
Ok(BKResponse::SearchEnd) => {
op.lock().unwrap().search_end();
}
Ok(BKResponse::NotificationClicked(msg)) => {
op.lock().unwrap().notification_cliked(msg);
}
Ok(BKResponse::NewRoom(r)) => {
op.lock().unwrap().new_room(r);
}
......@@ -2152,6 +2146,8 @@ fn backend_loop(op: Arc<Mutex<AppOp>>, rx: Receiver<BKResponse>) {
pub enum InternalCommand {
AddRoomMessage(Message, MsgPos, Option<Message>),
SetPanel(RoomPanel),
NotifyClicked(Message),
SelectRoom(Room),
}
......@@ -2165,6 +2161,12 @@ fn appop_loop(op: Arc<Mutex<AppOp>>, rx: Receiver<InternalCommand>) {
Ok(InternalCommand::SetPanel(st)) => {
op.lock().unwrap().room_panel(st);
}
Ok(InternalCommand::NotifyClicked(msg)) => {
op.lock().unwrap().notification_cliked(msg);
}
Ok(InternalCommand::SelectRoom(r)) => {
op.lock().unwrap().set_active_room_by_id(r.id);
}
Err(_) => {
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment