From 6a7beb57eec6104ad4a1aa5b23e93c3595c07fe0 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Fri, 15 Nov 2024 15:38:55 +0800 Subject: [PATCH] finalize startup logic --- apps/desktop/src-tauri/src/general_settings.rs | 3 ++- apps/desktop/src-tauri/src/lib.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rs index 0f941d71..47de3574 100644 --- a/apps/desktop/src-tauri/src/general_settings.rs +++ b/apps/desktop/src-tauri/src/general_settings.rs @@ -20,7 +20,8 @@ pub struct GeneralSettingsStore { pub enable_notifications: bool, #[serde(default)] pub disable_auto_open_links: bool, - #[serde(default)] + // first launch: store won't exist so show startup + #[serde(default = "true_b")] pub has_completed_startup: bool, } diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index a8ce7f0c..96fd02ba 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -2529,8 +2529,14 @@ pub async fn run() { let permissions = permissions::do_permissions_check(false); println!("Permissions check result: {:?}", permissions); - if !permissions.screen_recording.permitted() || !permissions.accessibility.permitted() { - println!("Required permissions not granted, showing permissions window"); + if !permissions.screen_recording.permitted() + || !permissions.accessibility.permitted() + || GeneralSettingsStore::get(app.handle()) + .ok() + .flatten() + .map(|s| !s.has_completed_startup) + .unwrap_or(false) + { CapWindow::Setup.show(&app_handle).ok(); } else { println!("Permissions granted, showing main window");