diff options
author | Ashelyn Rose <git@ashen.earth> | 2025-02-19 16:05:39 -0700 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2025-02-19 16:05:39 -0700 |
commit | 665a4904f89bb842a7ba211abdda62349eac8a03 (patch) | |
tree | 849235c7e531946c1c80c321c23be298c30ffec3 /app/src/oauth.rs | |
parent | e8314458ccdf4d3c68969b206cd29f2490fb6308 (diff) |
Simplify calling async from non-async inside oauth controller
Diffstat (limited to 'app/src/oauth.rs')
-rw-r--r-- | app/src/oauth.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/src/oauth.rs b/app/src/oauth.rs index 795d5dc..9334eac 100644 --- a/app/src/oauth.rs +++ b/app/src/oauth.rs @@ -1,12 +1,13 @@ use std::{collections::HashMap, sync::Arc}; use serde::Deserialize; +use tauri::async_runtime::RuntimeHandle; use tokio::sync::Mutex; use tokio::sync::oneshot::{channel, Sender, Receiver}; use uuid::Uuid; use crate::OAUTH_CLIENT_NAME; #[derive(Clone)] -pub struct OAuthController (Arc<Mutex<OAuthInternal>>); +pub struct OAuthController (Arc<Mutex<OAuthInternal>>, RuntimeHandle); type ServerDomain = String; type AccountIdentifier = String; @@ -50,11 +51,11 @@ pub struct AddServerResult { } impl OAuthController { - pub fn new() -> Self { + pub fn new(runtime_handle: RuntimeHandle) -> Self { Self(Arc::new(Mutex::new(OAuthInternal { servers: HashMap::new(), open_callbacks: HashMap::new(), - }))) + })), runtime_handle) } pub async fn add_server(&self, instance_domain: &str) -> Result<AddServerResult, String> { @@ -110,7 +111,7 @@ impl OAuthController { } pub fn resolve_code(&self, state: StateCode, auth_code: String) { - let runtime = tokio::runtime::Handle::current(); + let runtime = self.1.clone(); let inner_self = self.0.clone(); let state = state.clone(); |