From c77373bc67e9725973ce5738bafea1bf9d9154be Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Fri, 29 Mar 2024 22:23:19 +0900
Subject: [PATCH] refs #1395 Execute open url in another thread
---
src-tauri/src/main.rs | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index f1d63598..175edd9c 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -6,7 +6,7 @@ use base64::{engine::general_purpose, Engine};
use megalodon::{self, oauth};
use rust_i18n::t;
use serde::Serialize;
-use std::{env, fs::OpenOptions, path::PathBuf, str::FromStr, sync::Arc};
+use std::{env, fs::OpenOptions, path::PathBuf, str::FromStr, sync::Arc, thread};
use tauri::{api::shell, async_runtime::Mutex, AppHandle, Manager, State};
mod database;
mod entities;
@@ -105,7 +105,14 @@ async fn add_application(
let url = app_data.url.clone().expect("URL is not found");
tracing::info!("Opening the URL: {}", url);
- shell::open(&app_handle.shell_scope(), url, None).expect("Failed to open the URL");
+
+ let scope = app_handle.shell_scope().clone();
+ thread::spawn(move || match shell::open(&scope, url, None) {
+ Ok(_) => {}
+ Err(e) => {
+ tracing::error!("Failed to open the URL: {}", e);
+ }
+ });
Ok(app_data)
}