Avoid spurious notifies in chat channel select

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-10-02 15:57:59 -07:00
parent 1d5b665f13
commit 84c4db13fb

View file

@ -53,9 +53,11 @@ impl Select {
}
pub fn set_item_count(&mut self, count: usize, cx: &mut ViewContext<Self>) {
if count != self.item_count {
self.item_count = count;
cx.notify();
}
}
fn toggle(&mut self, cx: &mut ViewContext<Self>) {
self.is_open = !self.is_open;
@ -63,10 +65,12 @@ impl Select {
}
pub fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
if ix != self.selected_item_ix || self.is_open {
self.selected_item_ix = ix;
self.is_open = false;
cx.notify();
}
}
pub fn selected_index(&self) -> usize {
self.selected_item_ix