Use try_global()

This commit is contained in:
Joseph T. Lyons
2024-01-18 01:33:30 -05:00
parent 933fb87013
commit b807e6fe80
10 changed files with 52 additions and 70 deletions
+1 -5
View File
@@ -308,11 +308,7 @@ impl EventEmitter<Event> for Copilot {}
impl Copilot {
pub fn global(cx: &AppContext) -> Option<Model<Self>> {
if cx.has_global::<Model<Self>>() {
Some(cx.global::<Model<Self>>().clone())
} else {
None
}
cx.try_global::<Model<Self>>().map(|model| model.clone())
}
fn start(