Emit an event when adding a worktree to a project
This commit is contained in:
parent
04bd57b2c7
commit
a1a4c70845
2 changed files with 13 additions and 10 deletions
|
@ -2234,7 +2234,6 @@ mod tests {
|
||||||
.read_with(cx_a, |project, _| project.next_remote_id())
|
.read_with(cx_a, |project, _| project.next_remote_id())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project_a_events = Rc::new(RefCell::new(Vec::new()));
|
|
||||||
let user_b = client_a
|
let user_b = client_a
|
||||||
.user_store
|
.user_store
|
||||||
.update(cx_a, |store, cx| {
|
.update(cx_a, |store, cx| {
|
||||||
|
@ -2242,15 +2241,6 @@ mod tests {
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
project_a.update(cx_a, {
|
|
||||||
let project_a_events = project_a_events.clone();
|
|
||||||
move |_, cx| {
|
|
||||||
cx.subscribe(&cx.handle(), move |_, _, event, _| {
|
|
||||||
project_a_events.borrow_mut().push(event.clone());
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let (worktree_a, _) = project_a
|
let (worktree_a, _) = project_a
|
||||||
.update(cx_a, |p, cx| {
|
.update(cx_a, |p, cx| {
|
||||||
|
@ -2262,6 +2252,17 @@ mod tests {
|
||||||
.read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
|
.read_with(cx_a, |tree, _| tree.as_local().unwrap().scan_complete())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
let project_a_events = Rc::new(RefCell::new(Vec::new()));
|
||||||
|
project_a.update(cx_a, {
|
||||||
|
let project_a_events = project_a_events.clone();
|
||||||
|
move |_, cx| {
|
||||||
|
cx.subscribe(&cx.handle(), move |_, _, event, _| {
|
||||||
|
project_a_events.borrow_mut().push(event.clone());
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Request to join that project as client B
|
// Request to join that project as client B
|
||||||
let project_b = cx_b.spawn(|mut cx| {
|
let project_b = cx_b.spawn(|mut cx| {
|
||||||
let client = client_b.client.clone();
|
let client = client_b.client.clone();
|
||||||
|
|
|
@ -139,6 +139,7 @@ pub struct Collaborator {
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
ActiveEntryChanged(Option<ProjectEntryId>),
|
ActiveEntryChanged(Option<ProjectEntryId>),
|
||||||
|
WorktreeAdded,
|
||||||
WorktreeRemoved(WorktreeId),
|
WorktreeRemoved(WorktreeId),
|
||||||
DiskBasedDiagnosticsStarted,
|
DiskBasedDiagnosticsStarted,
|
||||||
DiskBasedDiagnosticsUpdated,
|
DiskBasedDiagnosticsUpdated,
|
||||||
|
@ -3637,6 +3638,7 @@ impl Project {
|
||||||
self.worktrees
|
self.worktrees
|
||||||
.push(WorktreeHandle::Weak(worktree.downgrade()));
|
.push(WorktreeHandle::Weak(worktree.downgrade()));
|
||||||
}
|
}
|
||||||
|
cx.emit(Event::WorktreeAdded);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue