fix windows startup crash (rookie mistake)
This commit is contained in:
@@ -19,10 +19,10 @@ pub async fn init(handle: &AppHandle) -> Result<(), String> {
|
||||
if settings.onboarding_done {
|
||||
start(handle).await;
|
||||
if cfg!(target_os = "macos") && !accessibility_permission_granted {
|
||||
crate::ui::onboarding::show_accessibility_page(handle)?;
|
||||
crate::ui::onboarding::show_accessibility_page(handle).await?;
|
||||
}
|
||||
} else {
|
||||
crate::ui::onboarding::show_initial(handle)?;
|
||||
crate::ui::onboarding::show_initial(handle).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ pub fn run() {
|
||||
.setup(move |app| {
|
||||
specta_builder.mount_events(app);
|
||||
let handle = app.handle().clone();
|
||||
ui::splashscreen::open(&handle)?;
|
||||
tauri::async_runtime::spawn(async move {
|
||||
ui::splashscreen::open(&handle).await.unwrap();
|
||||
let launch_result = launch_app(&handle).await.map_err(|error| error.to_string());
|
||||
|
||||
if let Err(error) = launch_result {
|
||||
@@ -69,7 +69,13 @@ pub fn run() {
|
||||
})
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while running tauri application")
|
||||
.run(|_, _| ());
|
||||
.run(|_, e| {
|
||||
if let tauri::RunEvent::ExitRequested { code, api, .. } = e {
|
||||
if code.is_none() {
|
||||
api.prevent_exit();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn specta_builder() -> tauri_specta::Builder<tauri::Wry> {
|
||||
|
||||
@@ -61,7 +61,7 @@ async fn apply_permission_state(handle: &AppHandle, granted: bool) -> Result<boo
|
||||
if granted {
|
||||
crate::application::reconcile_cursor(handle).await;
|
||||
} else {
|
||||
crate::ui::onboarding::show_accessibility_page(handle)?;
|
||||
crate::ui::onboarding::show_accessibility_page(handle).await?;
|
||||
}
|
||||
}
|
||||
Ok(true)
|
||||
|
||||
@@ -2,7 +2,7 @@ use tauri::{AppHandle, Manager, WebviewUrl};
|
||||
|
||||
const WINDOW_LABEL: &str = "onboarding";
|
||||
|
||||
fn show(handle: &AppHandle, accessibility_only: bool) -> Result<(), String> {
|
||||
async fn show(handle: &AppHandle, accessibility_only: bool) -> Result<(), String> {
|
||||
if let Some(window) = handle.get_webview_window(WINDOW_LABEL) {
|
||||
if accessibility_only {
|
||||
window
|
||||
@@ -44,10 +44,10 @@ fn show(handle: &AppHandle, accessibility_only: bool) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn show_initial(handle: &AppHandle) -> Result<(), String> {
|
||||
show(handle, false)
|
||||
pub async fn show_initial(handle: &AppHandle) -> Result<(), String> {
|
||||
show(handle, false).await
|
||||
}
|
||||
|
||||
pub fn show_accessibility_page(handle: &AppHandle) -> Result<(), String> {
|
||||
show(handle, true)
|
||||
pub async fn show_accessibility_page(handle: &AppHandle) -> Result<(), String> {
|
||||
show(handle, true).await
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ struct SplashscreenState {
|
||||
opened_at: Instant,
|
||||
}
|
||||
|
||||
pub fn open(handle: &AppHandle) -> Result<(), String> {
|
||||
pub async fn open(handle: &AppHandle) -> Result<(), String> {
|
||||
tauri::WebviewWindowBuilder::new(handle, WINDOW_LABEL, WebviewUrl::App("/splash.html".into()))
|
||||
.title("Friendolls")
|
||||
.inner_size(500.0, 290.0)
|
||||
|
||||
Reference in New Issue
Block a user