Move "async move" a few characters to the left in cx.spawn() (#26758)

This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-03-18 19:09:02 -07:00 committed by GitHub
parent 7f2e3fb5bd
commit 1aefa5178b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
256 changed files with 3110 additions and 3200 deletions

View file

@ -54,10 +54,10 @@ impl OneAtATime {
{
let (tx, rx) = oneshot::channel();
self.cancel.replace(tx);
cx.spawn(|cx| async move {
cx.spawn(async move |cx| {
futures::select_biased! {
_ = rx.fuse() => Ok(None),
result = f(cx).fuse() => result.map(Some),
result = f(cx.clone()).fuse() => result.map(Some),
}
})
}
@ -192,19 +192,19 @@ impl ActiveCall {
};
let invite = if let Some(room) = room {
cx.spawn(move |_, mut cx| async move {
cx.spawn(async move |_, cx| {
let room = room.await.map_err(|err| anyhow!("{:?}", err))?;
let initial_project_id = if let Some(initial_project) = initial_project {
Some(
room.update(&mut cx, |room, cx| room.share_project(initial_project, cx))?
room.update(cx, |room, cx| room.share_project(initial_project, cx))?
.await?,
)
} else {
None
};
room.update(&mut cx, move |room, cx| {
room.update(cx, move |room, cx| {
room.call(called_user_id, initial_project_id, cx)
})?
.await?;
@ -215,7 +215,7 @@ impl ActiveCall {
let client = self.client.clone();
let user_store = self.user_store.clone();
let room = cx
.spawn(move |this, mut cx| async move {
.spawn(async move |this, cx| {
let create_room = async {
let room = cx
.update(|cx| {
@ -229,14 +229,14 @@ impl ActiveCall {
})?
.await?;
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx))?
this.update(cx, |this, cx| this.set_room(Some(room.clone()), cx))?
.await?;
anyhow::Ok(room)
};
let room = create_room.await;
this.update(&mut cx, |this, _| this.pending_room_creation = None)?;
this.update(cx, |this, _| this.pending_room_creation = None)?;
room.map_err(Arc::new)
})
.shared();
@ -247,10 +247,10 @@ impl ActiveCall {
})
};
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let result = invite.await;
if result.is_ok() {
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.report_call_event("Participant Invited", cx)
})?;
} else {
@ -258,7 +258,7 @@ impl ActiveCall {
log::error!("invite failed: {:?}", result);
}
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.pending_invites.remove(&called_user_id);
cx.notify();
})?;
@ -315,11 +315,11 @@ impl ActiveCall {
._join_debouncer
.spawn(cx, move |cx| Room::join(room_id, client, user_store, cx));
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
this.update(cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.report_call_event("Incoming Call Accepted", cx)
})?;
Ok(())
@ -363,13 +363,11 @@ impl ActiveCall {
Room::join_channel(channel_id, client, user_store, cx).await
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
this.update(cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.report_call_event("Channel Joined", cx)
})?;
this.update(cx, |this, cx| this.report_call_event("Channel Joined", cx))?;
Ok(room)
})
}

View file

@ -128,7 +128,11 @@ impl Room {
let maintain_connection = cx.spawn({
let client = client.clone();
move |this, cx| Self::maintain_connection(this, client.clone(), cx).log_err()
async move |this, cx| {
Self::maintain_connection(this, client.clone(), cx)
.log_err()
.await
}
});
Audio::play_sound(Sound::Joined, cx);
@ -172,7 +176,7 @@ impl Room {
user_store: Entity<UserStore>,
cx: &mut App,
) -> Task<Result<Entity<Self>>> {
cx.spawn(move |mut cx| async move {
cx.spawn(async move |cx| {
let response = client.request(proto::CreateRoom {}).await?;
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
let room = cx.new(|cx| {
@ -192,7 +196,7 @@ impl Room {
let initial_project_id = if let Some(initial_project) = initial_project {
let initial_project_id = room
.update(&mut cx, |room, cx| {
.update(cx, |room, cx| {
room.share_project(initial_project.clone(), cx)
})?
.await?;
@ -202,7 +206,7 @@ impl Room {
};
let did_join = room
.update(&mut cx, |room, cx| {
.update(cx, |room, cx| {
room.leave_when_empty = true;
room.call(called_user_id, initial_project_id, cx)
})?
@ -358,7 +362,7 @@ impl Room {
async fn maintain_connection(
this: WeakEntity<Self>,
client: Arc<Client>,
mut cx: AsyncApp,
cx: &mut AsyncApp,
) -> Result<()> {
let mut client_status = client.status();
loop {
@ -370,7 +374,7 @@ impl Room {
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, cx| {
.update(cx, |this, cx| {
this.status = RoomStatus::Rejoining;
cx.notify();
})?;
@ -386,7 +390,7 @@ impl Room {
log::info!("client reconnected, attempting to rejoin room");
let Some(this) = this.upgrade() else { break };
match this.update(&mut cx, |this, cx| this.rejoin(cx)) {
match this.update(cx, |this, cx| this.rejoin(cx)) {
Ok(task) => {
if task.await.log_err().is_some() {
return true;
@ -435,7 +439,7 @@ impl Room {
// we leave the room and return an error.
if let Some(this) = this.upgrade() {
log::info!("reconnection failed, leaving room");
this.update(&mut cx, |this, cx| this.leave(cx))?.await?;
this.update(cx, |this, cx| this.leave(cx))?.await?;
}
Err(anyhow!(
"can't reconnect to room: client failed to re-establish connection"
@ -490,12 +494,12 @@ impl Room {
rejoined_projects,
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let response = response.await?;
let message_id = response.message_id;
let response = response.payload;
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.status = RoomStatus::Online;
this.apply_room_update(room_proto, cx)?;
@ -577,7 +581,7 @@ impl Room {
let client = self.client.clone();
let room_id = self.id;
let role = role.into();
cx.spawn(|_, _| async move {
cx.spawn(async move |_, _| {
client
.request(proto::SetRoomParticipantRole {
room_id,
@ -709,11 +713,11 @@ impl Room {
user_store.get_users(pending_participant_user_ids, cx),
)
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let (remote_participants, pending_participants) =
futures::join!(remote_participants, pending_participants);
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.participant_user_ids.clear();
if let Some(participant) = local_participant {
@ -1116,7 +1120,7 @@ impl Room {
let client = self.client.clone();
let room_id = self.id;
self.pending_call_count += 1;
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let result = client
.request(proto::Call {
room_id,
@ -1124,7 +1128,7 @@ impl Room {
initial_project_id,
})
.await;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.pending_call_count -= 1;
if this.should_leave() {
this.leave(cx).detach_and_log_err(cx);
@ -1145,11 +1149,11 @@ impl Room {
let client = self.client.clone();
let user_store = self.user_store.clone();
cx.emit(Event::RemoteProjectJoined { project_id: id });
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let project =
Project::in_room(id, client, user_store, language_registry, fs, cx.clone()).await?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.joined_projects.retain(|project| {
if let Some(project) = project.upgrade() {
!project.read(cx).is_disconnected(cx)
@ -1178,15 +1182,13 @@ impl Room {
is_ssh_project: project.read(cx).is_via_ssh(),
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let response = request.await?;
project.update(&mut cx, |project, cx| {
project.shared(response.project_id, cx)
})??;
project.update(cx, |project, cx| project.shared(response.project_id, cx))??;
// If the user's location is in this project, it changes from UnsharedProject to SharedProject.
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.shared_projects.insert(project.downgrade());
let active_project = this.local_participant.active_project.as_ref();
if active_project.map_or(false, |location| *location == project) {
@ -1342,7 +1344,7 @@ impl Room {
return Task::ready(Err(anyhow!("live-kit was not initialized")));
};
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let (track, stream) = capture_local_audio_track(cx.background_executor())?.await;
let publication = participant
@ -1355,7 +1357,7 @@ impl Room {
)
.await
.map_err(|error| anyhow!("failed to publish track: {error}"));
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
let live_kit = this
.live_kit
.as_mut()
@ -1428,7 +1430,7 @@ impl Room {
let sources = cx.screen_capture_sources();
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let sources = sources.await??;
let source = sources.first().ok_or_else(|| anyhow!("no display found"))?;
@ -1446,7 +1448,7 @@ impl Room {
.await
.map_err(|error| anyhow!("error publishing screen track {error:?}"));
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
let live_kit = this
.live_kit
.as_mut()
@ -1639,7 +1641,7 @@ fn spawn_room_connection(
cx: &mut Context<'_, Room>,
) {
if let Some(connection_info) = livekit_connection_info {
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let (room, mut events) = livekit::Room::connect(
&connection_info.server_url,
&connection_info.token,
@ -1647,11 +1649,11 @@ fn spawn_room_connection(
)
.await?;
this.update(&mut cx, |this, cx| {
let _handle_updates = cx.spawn(|this, mut cx| async move {
this.update(cx, |this, cx| {
let _handle_updates = cx.spawn(async move |this, cx| {
while let Some(event) = events.recv().await {
if this
.update(&mut cx, |this, cx| {
.update(cx, |this, cx| {
this.livekit_room_updated(event, cx).warn_on_err();
})
.is_err()

View file

@ -47,10 +47,10 @@ impl OneAtATime {
{
let (tx, rx) = oneshot::channel();
self.cancel.replace(tx);
cx.spawn(|cx| async move {
cx.spawn(async move |cx| {
futures::select_biased! {
_ = rx.fuse() => Ok(None),
result = f(cx).fuse() => result.map(Some),
result = f(cx.clone()).fuse() => result.map(Some),
}
})
}
@ -185,19 +185,19 @@ impl ActiveCall {
};
let invite = if let Some(room) = room {
cx.spawn(move |_, mut cx| async move {
cx.spawn(async move |_, cx| {
let room = room.await.map_err(|err| anyhow!("{:?}", err))?;
let initial_project_id = if let Some(initial_project) = initial_project {
Some(
room.update(&mut cx, |room, cx| room.share_project(initial_project, cx))?
room.update(cx, |room, cx| room.share_project(initial_project, cx))?
.await?,
)
} else {
None
};
room.update(&mut cx, move |room, cx| {
room.update(cx, move |room, cx| {
room.call(called_user_id, initial_project_id, cx)
})?
.await?;
@ -208,7 +208,7 @@ impl ActiveCall {
let client = self.client.clone();
let user_store = self.user_store.clone();
let room = cx
.spawn(move |this, mut cx| async move {
.spawn(async move |this, cx| {
let create_room = async {
let room = cx
.update(|cx| {
@ -222,14 +222,14 @@ impl ActiveCall {
})?
.await?;
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx))?
this.update(cx, |this, cx| this.set_room(Some(room.clone()), cx))?
.await?;
anyhow::Ok(room)
};
let room = create_room.await;
this.update(&mut cx, |this, _| this.pending_room_creation = None)?;
this.update(cx, |this, _| this.pending_room_creation = None)?;
room.map_err(Arc::new)
})
.shared();
@ -240,10 +240,10 @@ impl ActiveCall {
})
};
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let result = invite.await;
if result.is_ok() {
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.report_call_event("Participant Invited", cx)
})?;
} else {
@ -251,7 +251,7 @@ impl ActiveCall {
log::error!("invite failed: {:?}", result);
}
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.pending_invites.remove(&called_user_id);
cx.notify();
})?;
@ -304,15 +304,15 @@ impl ActiveCall {
let room_id = call.room_id;
let client = self.client.clone();
let user_store = self.user_store.clone();
let join = self
._join_debouncer
.spawn(cx, move |cx| Room::join(room_id, client, user_store, cx));
let join = self._join_debouncer.spawn(cx, move |mut cx| async move {
Room::join(room_id, client, user_store, &mut cx).await
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
this.update(cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.report_call_event("Incoming Call Accepted", cx)
})?;
Ok(())
@ -352,17 +352,15 @@ impl ActiveCall {
let client = self.client.clone();
let user_store = self.user_store.clone();
let join = self._join_debouncer.spawn(cx, move |cx| async move {
Room::join_channel(channel_id, client, user_store, cx).await
let join = self._join_debouncer.spawn(cx, move |mut cx| async move {
Room::join_channel(channel_id, client, user_store, &mut cx).await
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let room = join.await?;
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
this.update(cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
this.report_call_event("Channel Joined", cx)
})?;
this.update(cx, |this, cx| this.report_call_event("Channel Joined", cx))?;
Ok(room)
})
}

View file

@ -115,7 +115,7 @@ impl Room {
let mut status = room.status();
// Consume the initial status of the room.
let _ = status.try_recv();
let _maintain_room = cx.spawn(|this, mut cx| async move {
let _maintain_room = cx.spawn(async move |this, cx| {
while let Some(status) = status.next().await {
let this = if let Some(this) = this.upgrade() {
this
@ -124,8 +124,7 @@ impl Room {
};
if status == livekit_client_macos::ConnectionState::Disconnected {
this.update(&mut cx, |this, cx| this.leave(cx).log_err())
.ok();
this.update(cx, |this, cx| this.leave(cx).log_err()).ok();
break;
}
}
@ -133,7 +132,7 @@ impl Room {
let _handle_updates = cx.spawn({
let room = room.clone();
move |this, mut cx| async move {
async move |this, cx| {
let mut updates = room.updates();
while let Some(update) = updates.next().await {
let this = if let Some(this) = this.upgrade() {
@ -142,7 +141,7 @@ impl Room {
break;
};
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.live_kit_room_updated(update, cx).log_err()
})
.ok();
@ -151,9 +150,9 @@ impl Room {
});
let connect = room.connect(&connection_info.server_url, &connection_info.token);
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
connect.await?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
if this.can_use_microphone() {
if let Some(live_kit) = &this.live_kit {
if !live_kit.muted_by_user && !live_kit.deafened {
@ -184,7 +183,11 @@ impl Room {
let maintain_connection = cx.spawn({
let client = client.clone();
move |this, cx| Self::maintain_connection(this, client.clone(), cx).log_err()
async move |this, cx| {
Self::maintain_connection(this, client.clone(), cx)
.log_err()
.await
}
});
Audio::play_sound(Sound::Joined, cx);
@ -228,7 +231,7 @@ impl Room {
user_store: Entity<UserStore>,
cx: &mut App,
) -> Task<Result<Entity<Self>>> {
cx.spawn(move |mut cx| async move {
cx.spawn(async move |cx| {
let response = client.request(proto::CreateRoom {}).await?;
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
let room = cx.new(|cx| {
@ -248,7 +251,7 @@ impl Room {
let initial_project_id = if let Some(initial_project) = initial_project {
let initial_project_id = room
.update(&mut cx, |room, cx| {
.update(cx, |room, cx| {
room.share_project(initial_project.clone(), cx)
})?
.await?;
@ -258,7 +261,7 @@ impl Room {
};
let did_join = room
.update(&mut cx, |room, cx| {
.update(cx, |room, cx| {
room.leave_when_empty = true;
room.call(called_user_id, initial_project_id, cx)
})?
@ -274,7 +277,7 @@ impl Room {
channel_id: ChannelId,
client: Arc<Client>,
user_store: Entity<UserStore>,
cx: AsyncApp,
cx: &mut AsyncApp,
) -> Result<Entity<Self>> {
Self::from_join_response(
client
@ -292,7 +295,7 @@ impl Room {
room_id: u64,
client: Arc<Client>,
user_store: Entity<UserStore>,
cx: AsyncApp,
cx: &mut AsyncApp,
) -> Result<Entity<Self>> {
Self::from_join_response(
client.request(proto::JoinRoom { id: room_id }).await?,
@ -333,7 +336,7 @@ impl Room {
response: proto::JoinRoomResponse,
client: Arc<Client>,
user_store: Entity<UserStore>,
mut cx: AsyncApp,
cx: &mut AsyncApp,
) -> Result<Entity<Self>> {
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
let room = cx.new(|cx| {
@ -346,7 +349,7 @@ impl Room {
cx,
)
})?;
room.update(&mut cx, |room, cx| {
room.update(cx, |room, cx| {
room.leave_when_empty = room.channel_id.is_none();
room.apply_room_update(room_proto, cx)?;
anyhow::Ok(())
@ -414,7 +417,7 @@ impl Room {
async fn maintain_connection(
this: WeakEntity<Self>,
client: Arc<Client>,
mut cx: AsyncApp,
cx: &mut AsyncApp,
) -> Result<()> {
let mut client_status = client.status();
loop {
@ -426,7 +429,7 @@ impl Room {
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, cx| {
.update(cx, |this, cx| {
this.status = RoomStatus::Rejoining;
cx.notify();
})?;
@ -442,7 +445,7 @@ impl Room {
log::info!("client reconnected, attempting to rejoin room");
let Some(this) = this.upgrade() else { break };
match this.update(&mut cx, |this, cx| this.rejoin(cx)) {
match this.update(cx, |this, cx| this.rejoin(cx)) {
Ok(task) => {
if task.await.log_err().is_some() {
return true;
@ -491,7 +494,7 @@ impl Room {
// we leave the room and return an error.
if let Some(this) = this.upgrade() {
log::info!("reconnection failed, leaving room");
this.update(&mut cx, |this, cx| this.leave(cx))?.await?;
this.update(cx, |this, cx| this.leave(cx))?.await?;
}
Err(anyhow!(
"can't reconnect to room: client failed to re-establish connection"
@ -546,12 +549,12 @@ impl Room {
rejoined_projects,
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let response = response.await?;
let message_id = response.message_id;
let response = response.payload;
let room_proto = response.room.ok_or_else(|| anyhow!("invalid room"))?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.status = RoomStatus::Online;
this.apply_room_update(room_proto, cx)?;
@ -633,7 +636,7 @@ impl Room {
let client = self.client.clone();
let room_id = self.id;
let role = role.into();
cx.spawn(|_, _| async move {
cx.spawn(async move |_, _| {
client
.request(proto::SetRoomParticipantRole {
room_id,
@ -736,11 +739,11 @@ impl Room {
)
});
self.pending_room_update = Some(cx.spawn(|this, mut cx| async move {
self.pending_room_update = Some(cx.spawn(async move |this, cx| {
let (remote_participants, pending_participants) =
futures::join!(remote_participants, pending_participants);
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.participant_user_ids.clear();
if let Some(participant) = local_participant {
@ -1136,7 +1139,7 @@ impl Room {
let client = self.client.clone();
let room_id = self.id;
self.pending_call_count += 1;
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let result = client
.request(proto::Call {
room_id,
@ -1144,7 +1147,7 @@ impl Room {
initial_project_id,
})
.await;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.pending_call_count -= 1;
if this.should_leave() {
this.leave(cx).detach_and_log_err(cx);
@ -1165,11 +1168,11 @@ impl Room {
let client = self.client.clone();
let user_store = self.user_store.clone();
cx.emit(Event::RemoteProjectJoined { project_id: id });
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let project =
Project::in_room(id, client, user_store, language_registry, fs, cx.clone()).await?;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.joined_projects.retain(|project| {
if let Some(project) = project.upgrade() {
!project.read(cx).is_disconnected(cx)
@ -1198,15 +1201,13 @@ impl Room {
is_ssh_project: project.read(cx).is_via_ssh(),
});
cx.spawn(|this, mut cx| async move {
cx.spawn(async move |this, cx| {
let response = request.await?;
project.update(&mut cx, |project, cx| {
project.shared(response.project_id, cx)
})??;
project.update(cx, |project, cx| project.shared(response.project_id, cx))??;
// If the user's location is in this project, it changes from UnsharedProject to SharedProject.
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.shared_projects.insert(project.downgrade());
let active_project = this.local_participant.active_project.as_ref();
if active_project.map_or(false, |location| *location == project) {
@ -1348,12 +1349,12 @@ impl Room {
return Task::ready(Err(anyhow!("live-kit was not initialized")));
};
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let publish_track = async {
let track = LocalAudioTrack::create();
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, _| {
.update(cx, |this, _| {
this.live_kit
.as_ref()
.map(|live_kit| live_kit.room.publish_audio_track(track))
@ -1364,7 +1365,7 @@ impl Room {
let publication = publish_track.await;
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, cx| {
.update(cx, |this, cx| {
let live_kit = this
.live_kit
.as_mut()
@ -1424,7 +1425,7 @@ impl Room {
return Task::ready(Err(anyhow!("live-kit was not initialized")));
};
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let publish_track = async {
let displays = displays.await?;
let display = displays
@ -1433,7 +1434,7 @@ impl Room {
let track = LocalVideoTrack::screen_share_for_display(display);
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, _| {
.update(cx, |this, _| {
this.live_kit
.as_ref()
.map(|live_kit| live_kit.room.publish_video_track(track))
@ -1445,7 +1446,7 @@ impl Room {
let publication = publish_track.await;
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, cx| {
.update(cx, |this, cx| {
let live_kit = this
.live_kit
.as_mut()