Use try_global()
This commit is contained in:
parent
933fb87013
commit
b807e6fe80
10 changed files with 52 additions and 70 deletions
|
@ -586,13 +586,9 @@ impl<T: Item> ItemHandle for View<T> {
|
|||
}
|
||||
|
||||
fn to_followable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn FollowableItemHandle>> {
|
||||
if cx.has_global::<FollowableItemBuilders>() {
|
||||
let builders = cx.global::<FollowableItemBuilders>();
|
||||
let item = self.to_any();
|
||||
Some(builders.get(&item.entity_type())?.1(&item))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let builders = cx.try_global::<FollowableItemBuilders>()?;
|
||||
let item = self.to_any();
|
||||
Some(builders.get(&item.entity_type())?.1(&item))
|
||||
}
|
||||
|
||||
fn on_release(
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue