mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 18:41:10 +00:00
Ensure sharing the same project twice is idempotent
This commit is contained in:
parent
d3cddfdced
commit
6fb5901d69
2 changed files with 16 additions and 0 deletions
|
@ -299,6 +299,12 @@ impl Room {
|
|||
project: ModelHandle<Project>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<u64>> {
|
||||
if project.read(cx).is_remote() {
|
||||
return Task::ready(Err(anyhow!("can't share remote project")));
|
||||
} else if let Some(project_id) = project.read(cx).remote_id() {
|
||||
return Task::ready(Ok(project_id));
|
||||
}
|
||||
|
||||
let request = self
|
||||
.client
|
||||
.request(proto::ShareProject { room_id: self.id() });
|
||||
|
|
|
@ -838,6 +838,16 @@ async fn test_active_call_events(
|
|||
);
|
||||
assert_eq!(mem::take(&mut *events_b.borrow_mut()), vec![]);
|
||||
|
||||
// Sharing a project twice is idempotent.
|
||||
let project_b_id_2 = active_call_b
|
||||
.update(cx_b, |call, cx| call.share_project(project_b.clone(), cx))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(project_b_id_2, project_b_id);
|
||||
deterministic.run_until_parked();
|
||||
assert_eq!(mem::take(&mut *events_a.borrow_mut()), vec![]);
|
||||
assert_eq!(mem::take(&mut *events_b.borrow_mut()), vec![]);
|
||||
|
||||
fn active_call_events(cx: &mut TestAppContext) -> Rc<RefCell<Vec<room::Event>>> {
|
||||
let events = Rc::new(RefCell::new(Vec::new()));
|
||||
let active_call = cx.read(ActiveCall::global);
|
||||
|
|
Loading…
Reference in a new issue