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

@ -275,11 +275,8 @@ pub struct SearchResult {
impl SemanticIndex {
pub fn global(cx: &mut AppContext) -> Option<Model<SemanticIndex>> {
if cx.has_global::<Model<Self>>() {
Some(cx.global::<Model<SemanticIndex>>().clone())
} else {
None
}
cx.try_global::<Model<Self>>()
.map(|semantic_index| semantic_index.clone())
}
pub fn authenticate(&mut self, cx: &mut AppContext) -> bool {