Skip to content

Commit

Permalink
style(volumes-panel): Avoid no-result-page on switching connection
Browse files Browse the repository at this point in the history
  • Loading branch information
marhkb committed Oct 12, 2024
1 parent 7e56680 commit 02f45a8
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/view/volumes_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,27 @@ mod imp {
view::VolumeRow::from(item.downcast_ref().unwrap()).upcast()
});

self.filter_stack
.set_visible_child_name(if model.n_items() > 0 { "list" } else { "empty" });
model.connect_items_changed(clone!(@weak obj => move |model, _, removed, _| {
obj.imp()
.filter_stack
.set_visible_child_name(if model.n_items() > 0 { "list" } else { "empty" });

if removed > 0 {
obj.deselect_hidden_volumes(model.upcast_ref());
model.connect_items_changed(clone!(
#[weak]
obj,
move |model, _, removed, _| {
obj.imp().filter_stack.set_visible_child_name(
if model.n_items() > 0 || {
!obj.volume_list()
.as_ref()
.is_some_and(model::VolumeList::initialized)
} {
"list"
} else {
"empty"
},
);

if removed > 0 {
obj.deselect_hidden_volumes(model.upcast_ref());
}
}
}));
));
}

self.volume_list.set(value);
Expand Down

0 comments on commit 02f45a8

Please sign in to comment.