Merge pull request #314 from zed-industries/auto-connect

Auto-connect to server on startup if credentials are on the keychain
This commit is contained in:
Antonio Scandurra 2022-01-11 18:34:20 +01:00 committed by GitHub
commit 89ead1c44d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -346,6 +346,10 @@ impl Client {
}
}
pub fn has_keychain_credentials(&self, cx: &AsyncAppContext) -> bool {
read_credentials_from_keychain(cx).is_some()
}
#[async_recursion(?Send)]
pub async fn authenticate_and_connect(
self: &Arc<Self>,

View file

@ -61,6 +61,16 @@ fn main() {
chat_panel::init(cx);
project_panel::init(cx);
diagnostics::init(cx);
cx.spawn({
let client = client.clone();
|cx| async move {
if client.has_keychain_credentials(&cx) {
client.authenticate_and_connect(&cx).await?;
}
Ok::<_, anyhow::Error>(())
}
})
.detach_and_log_err(cx);
let app_state = Arc::new(AppState {
languages: languages.clone(),