Fix channel drag and drop

Also add the ability to unnest a channel by dragging it to the "Channels"
header. This is currently not working due to a collab server issue.

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Marshall Bowers 2023-12-15 14:01:24 -05:00
parent a40f04b71f
commit 5417127902

View file

@ -2225,14 +2225,14 @@ impl CollabPanel {
.selected(is_selected),
)
.when(section == Section::Channels, |el| {
el.drag_over::<DraggedChannelView>(|style| {
el.drag_over::<Channel>(|style| {
style.bg(cx.theme().colors().ghost_element_hover)
})
.on_drop(cx.listener(
move |this, view: &View<DraggedChannelView>, cx| {
move |this, dragged_channel: &Channel, cx| {
this.channel_store
.update(cx, |channel_store, cx| {
channel_store.move_channel(view.read(cx).channel.id, None, cx)
channel_store.move_channel(dragged_channel.id, None, cx)
})
.detach_and_log_err(cx)
},
@ -2451,15 +2451,15 @@ impl CollabPanel {
width,
})
})
.drag_over::<DraggedChannelView>(|style| {
.drag_over::<Channel>(|style| {
style.bg(cx.theme().colors().ghost_element_hover)
})
.on_drop(
cx.listener(move |this, view: &View<DraggedChannelView>, cx| {
cx.listener(move |this, dragged_channel: &Channel, cx| {
this.channel_store
.update(cx, |channel_store, cx| {
channel_store.move_channel(
view.read(cx).channel.id,
dragged_channel.id,
Some(channel_id),
cx,
)