diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b35c1cd..ff45c2f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.0.4", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.0.5", features = ["api-all", "system-tray"] } +tauri = { version = "1.0.5", features = ["api-all", "dialog", "system-tray"] } sodiumoxide = "0.2.7" tokio = { version = ">=1.19", features = ["full"] } sqlx = { version = "0.6.2", features = ["sqlite", "runtime-tokio-rustls"] } @@ -37,10 +37,10 @@ dirs = "5.0" [features] # by default Tauri runs in production mode # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL -default = [ "custom-protocol" ] +default = ["custom-protocol"] # this feature is used used for production builds where `devPath` points to the filesystem # DO NOT remove this -custom-protocol = [ "tauri/custom-protocol" ] +custom-protocol = ["tauri/custom-protocol"] # [profile.dev.build-override] # opt-level = 3 diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 05e4e94..2a169bb 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -90,6 +90,7 @@ pub fn set_auto_launch(is_configured: bool) -> Result<(), SetupError> { pub fn get_or_create_db_path() -> Result { + // debug_assertions doesn't always mean we are running in dev if cfg!(debug_assertions) && std::env::var("HOME").is_ok() { return Ok(PathBuf::from("./creddy.db")); } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 1b93e4b..895ceb4 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,7 +3,9 @@ windows_subsystem = "windows" )] use std::error::Error; +use std::sync::mpsc::channel; +use once_cell::sync::OnceCell; use sqlx::{ SqlitePool, sqlite::SqlitePoolOptions, @@ -15,7 +17,10 @@ use tauri::{ Manager, async_runtime as rt, }; -use once_cell::sync::OnceCell; +use tauri::api::dialog::{ + MessageDialogBuilder, + MessageDialogKind, +}; mod config; mod errors; @@ -61,7 +66,7 @@ async fn setup(app: &mut App) -> Result<(), Box> { } -fn main() { +fn run() -> tauri::Result<()> { tauri::Builder::default() .system_tray(tray::create()) .on_system_tray_event(tray::handle_event) @@ -74,8 +79,7 @@ fn main() { ipc::save_config, ]) .setup(|app| rt::block_on(setup(app))) - .build(tauri::generate_context!()) - .expect("error while running tauri application") + .build(tauri::generate_context!())? .run(|app, run_event| match run_event { tauri::RunEvent::WindowEvent { label, event, .. } => match event { tauri::WindowEvent::CloseRequested { api, .. } => { @@ -85,7 +89,23 @@ fn main() { _ => () } _ => () - }) + }); + + Ok(()) +} + + +fn main() { + if let Err(e) = run() { + let (tx, rx) = channel(); + MessageDialogBuilder::new( + "Creddy failed to start", + format!("{e}") + ) + .kind(MessageDialogKind::Error) + .show(move |_| tx.send(true).unwrap()); + rx.recv().unwrap(); + } } diff --git a/src/ui/Link.svelte b/src/ui/Link.svelte index 6515fbf..38f2da9 100644 --- a/src/ui/Link.svelte +++ b/src/ui/Link.svelte @@ -29,10 +29,7 @@ if (alt && !event.altKey) return; if (shift && !event.shiftKey) return; - if (event.code === hotkey) { - click(); - } - else if (hotkey === 'Enter' && event.code === 'NumpadEnter') { + if (event.key === hotkey) { click(); } } @@ -41,6 +38,6 @@ - + diff --git a/src/views/Settings.svelte b/src/views/Settings.svelte index a0a5477..5191184 100644 --- a/src/views/Settings.svelte +++ b/src/views/Settings.svelte @@ -1,5 +1,6 @@ @@ -52,7 +56,12 @@ - + Listen for credentials requests on this port. (Should be used with $AWS_CONTAINER_CREDENTIALS_FULL_URI)