Avoid spurious notifies in chat channel select
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
1d5b665f13
commit
84c4db13fb
1 changed files with 9 additions and 5 deletions
|
@ -53,8 +53,10 @@ impl Select {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_item_count(&mut self, count: usize, cx: &mut ViewContext<Self>) {
|
pub fn set_item_count(&mut self, count: usize, cx: &mut ViewContext<Self>) {
|
||||||
self.item_count = count;
|
if count != self.item_count {
|
||||||
cx.notify();
|
self.item_count = count;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle(&mut self, cx: &mut ViewContext<Self>) {
|
fn toggle(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
@ -63,9 +65,11 @@ impl Select {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
|
pub fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
|
||||||
self.selected_item_ix = ix;
|
if ix != self.selected_item_ix || self.is_open {
|
||||||
self.is_open = false;
|
self.selected_item_ix = ix;
|
||||||
cx.notify();
|
self.is_open = false;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selected_index(&self) -> usize {
|
pub fn selected_index(&self) -> usize {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue