sidebar: clenup code for room selection

This commit is contained in:
Julian Sparber 2018-12-13 18:02:47 +01:00
parent 0a686c5eaa
commit ab013749e2
3 changed files with 4 additions and 21 deletions

View file

@ -78,8 +78,6 @@ impl AppOp {
.get_object("room_container")
.expect("Couldn't find room_container in ui file.");
let selected_room = self.roomlist.get_selected();
self.rooms.clear();
for ch in container.get_children().iter() {
container.remove(ch);
@ -100,7 +98,6 @@ impl AppOp {
self.roomlist = widgets::RoomList::new(Some(self.server_url.clone()));
self.roomlist.add_rooms(rooms.iter().cloned().collect());
container.add(self.roomlist.widget());
self.roomlist.set_selected(selected_room);
let bk = self.backend.clone();
self.roomlist.connect_fav(move |room, tofav| {
@ -269,7 +266,6 @@ impl AppOp {
let fakeroom = Room::new(internal_id.clone(), Some(n));
self.new_room(fakeroom, None);
self.roomlist.set_selected(Some(internal_id.clone()));
self.set_active_room_by_id(internal_id);
self.room_panel(RoomPanel::Room);
}
@ -297,8 +293,10 @@ impl AppOp {
"noroom" => {
for ch in headerbar.get_children().iter() {
ch.hide();
// Select new active room in the sidebar
self.roomlist.unselect();
}
self.roomlist.set_selected(None);
}
"room_view" => {
for ch in headerbar.get_children().iter() {
@ -447,7 +445,6 @@ impl AppOp {
self.roomlist.add_room(r.clone());
self.roomlist.moveup(r.id.clone());
self.roomlist.set_selected(Some(r.id.clone()));
self.set_active_room_by_id(r.id);
}

View file

@ -29,7 +29,6 @@ impl AppOp {
fakeroom.direct = true;
self.new_room(fakeroom, None);
self.roomlist.set_selected(Some(internal_id.clone()));
self.set_active_room_by_id(internal_id);
self.room_panel(RoomPanel::Room);
}

View file

@ -451,23 +451,10 @@ impl RoomList {
run_in_group!(self, &r.to_string(), set_selected, Some(r.to_string()));
}
pub fn set_selected(&self, room: Option<String>) {
pub fn unselect(&self) {
self.inv.get().set_selected(None);
self.fav.get().set_selected(None);
self.rooms.get().set_selected(None);
if let Some(r) = room {
run_in_group!(self, &r, set_selected, Some(r.clone()));
}
}
pub fn get_selected(&self) -> Option<String> {
for i in [&self.inv, &self.fav, &self.rooms].iter() {
if let Some(s) = i.get().get_selected() {
return Some(s.clone());
}
}
None
}
pub fn add_rooms(&mut self, array: Vec<Room>) {