mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 19:02:07 +00:00
Implement channel switching
This commit is contained in:
parent
836b6dfbaf
commit
1d697df1bc
2 changed files with 16 additions and 0 deletions
|
@ -75,6 +75,10 @@ impl Select {
|
||||||
self.is_open = false;
|
self.is_open = false;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn selected_index(&self) -> usize {
|
||||||
|
self.selected_item_ix
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Entity for Select {
|
impl Entity for Select {
|
||||||
|
|
|
@ -99,6 +99,18 @@ impl ChatPanel {
|
||||||
this.init_active_channel(cx);
|
this.init_active_channel(cx);
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
cx.observe(&this.channel_select, |this, channel_select, cx| {
|
||||||
|
let selected_ix = channel_select.read(cx).selected_index();
|
||||||
|
let selected_channel = this.channel_list.update(cx, |channel_list, cx| {
|
||||||
|
let available_channels = channel_list.available_channels()?;
|
||||||
|
let channel_id = available_channels.get(selected_ix)?.id;
|
||||||
|
channel_list.get_channel(channel_id, cx)
|
||||||
|
});
|
||||||
|
if let Some(selected_channel) = selected_channel {
|
||||||
|
this.set_active_channel(selected_channel, cx);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue