WIP - Start work on unfollowing automatically
This commit is contained in:
parent
1728551282
commit
c550fc3f01
2 changed files with 20 additions and 0 deletions
|
@ -158,6 +158,10 @@ impl FollowableItem for Editor {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_unfollow_on_event(event: &Self::Event, cx: &AppContext) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_selection(selection: &Selection<Anchor>) -> proto::Selection {
|
||||
|
|
|
@ -270,6 +270,7 @@ pub trait FollowableItem: Item {
|
|||
message: proto::update_view::Variant,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Result<()>;
|
||||
fn should_unfollow_on_event(event: &Self::Event, cx: &AppContext) -> bool;
|
||||
}
|
||||
|
||||
pub trait FollowableItemHandle: ItemHandle {
|
||||
|
@ -285,6 +286,7 @@ pub trait FollowableItemHandle: ItemHandle {
|
|||
message: proto::update_view::Variant,
|
||||
cx: &mut MutableAppContext,
|
||||
) -> Result<()>;
|
||||
fn should_unfollow_on_event(&self, event: &dyn Any, cx: &AppContext) -> bool;
|
||||
}
|
||||
|
||||
impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
||||
|
@ -313,6 +315,14 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
|||
) -> Result<()> {
|
||||
self.update(cx, |this, cx| this.apply_update_message(message, cx))
|
||||
}
|
||||
|
||||
fn should_unfollow_on_event(&self, event: &dyn Any, cx: &AppContext) -> bool {
|
||||
if let Some(event) = event.downcast_ref() {
|
||||
T::should_unfollow_on_event(event, cx)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ItemHandle: 'static + fmt::Debug {
|
||||
|
@ -421,6 +431,12 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
|||
return;
|
||||
};
|
||||
|
||||
if let Some(item) = item.to_followable_item_handle(cx) {
|
||||
if item.should_unfollow_on_event(event, cx) {
|
||||
workspace.unfollow(&pane, cx);
|
||||
}
|
||||
}
|
||||
|
||||
if T::should_close_item_on_event(event) {
|
||||
pane.update(cx, |pane, cx| pane.close_item(item.id(), cx));
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue