move re-hide to main request handler

This commit is contained in:
Joseph Montanaro committed 2022-12-21 16:04:12 -08:00
1 parent 5ffa55c03c
commit bf4c46238e
6 files changed
+51 -33

No files matched your search

+3 -17
View File
@@ -1,8 +1,5 @@
use core::time::Duration;
use serde::{Serialize, Deserialize};
use tauri::State;
use tokio::time::sleep;
use crate::clientinfo::Client;
use crate::state::{AppState, Session, Credentials};
@@ -30,20 +27,9 @@ pub enum Approval {
#[tauri::command]
pub fn respond(
response: RequestResponse,
window: tauri::Window,
app_state: State<'_, AppState>
) -> Result<(), String> {
pub fn respond(response: RequestResponse, app_state: State<'_, AppState>) -> Result<(), String> {
app_state.send_response(response)
.map_err(|e| format!("Error responding to request: {e}"))?;
tauri::async_runtime::spawn(async move {
sleep(Duration::from_secs(3)).await;
let _ = window.hide();
});
Ok(())
.map_err(|e| format!("Error responding to request: {e}"))
}
@@ -74,5 +60,5 @@ pub async fn save_credentials(
) -> Result<(), String> {
app_state.save_creds(credentials, &passphrase)
.await
.map_err(|e| e.to_string())
.map_err(|e| {eprintln!("{e:?}"); e.to_string()})
}