Skip to content

Commit

Permalink
Merge pull request #1415 from h3poteto/iss-1395/spawn
Browse files Browse the repository at this point in the history
refs #1395 Execute open url in another thread
  • Loading branch information
h3poteto authored Mar 29, 2024
2 parents 587ad2a + c77373b commit 2bfdced
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 2bfdced

Please sign in to comment.