Use try_global()

This commit is contained in:
Joseph T. Lyons 2024-01-18 00:58:50 -05:00
parent 933fb87013
commit b807e6fe80
10 changed files with 52 additions and 70 deletions

View file

@ -616,8 +616,8 @@ impl Workspace {
let modal_layer = cx.new_view(|_| ModalLayer::new());
let mut active_call = None;
if cx.has_global::<Model<ActiveCall>>() {
let call = cx.global::<Model<ActiveCall>>().clone();
if let Some(call) = cx.try_global::<Model<ActiveCall>>() {
let call = call.clone();
let mut subscriptions = Vec::new();
subscriptions.push(cx.subscribe(&call, Self::on_active_call_event));
active_call = Some((call, subscriptions));
@ -3686,11 +3686,8 @@ impl WorkspaceStore {
update: proto::update_followers::Variant,
cx: &AppContext,
) -> Option<()> {
if !cx.has_global::<Model<ActiveCall>>() {
return None;
}
let room_id = ActiveCall::global(cx).read(cx).room()?.read(cx).id();
let active_call = cx.try_global::<Model<ActiveCall>>()?;
let room_id = active_call.read(cx).room()?.read(cx).id();
let follower_ids: Vec<_> = self
.followers
.iter()