Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #1492 Use open instead of tauri shell #1495

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ once_cell = "1.19.0"
rust-i18n = "3.0.1"
base64 = "0.21"
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
open = "5.1.3"

[features]
# by default Tauri runs in production mode
Expand Down
14 changes: 4 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use megalodon::{self, oauth};
use rust_i18n::t;
use serde::Serialize;
use std::{env, fs::OpenOptions, path::PathBuf, str::FromStr, sync::Arc, thread};
use tauri::{api::shell, async_runtime::Mutex, AppHandle, Manager, State};
use tauri::{async_runtime::Mutex, AppHandle, Manager, State};
mod database;
mod entities;
mod favicon;
Expand Down Expand Up @@ -88,7 +88,6 @@ async fn remove_server(

#[tauri::command]
async fn add_application(
app_handle: AppHandle,
_sqlite_pool: State<'_, sqlx::SqlitePool>,
url: &str,
) -> Result<oauth::AppData, String> {
Expand All @@ -106,8 +105,7 @@ async fn add_application(
let url = app_data.url.clone().expect("URL is not found");
tracing::info!("Opening the URL: {}", url);

let scope = app_handle.shell_scope().clone();
thread::spawn(move || match shell::open(&scope, url, None) {
thread::spawn(move || match open::that(url) {
Ok(_) => {}
Err(e) => {
tracing::error!("Failed to open the URL: {}", e);
Expand Down Expand Up @@ -652,12 +650,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.menu(menu::menu())
.on_menu_event(|event| match event.menu_item_id() {
"crash_reporting" => {
shell::open(
&event.window().app_handle().shell_scope(),
"https://fedistar.net/help#crash_reporting",
None,
)
.expect("Failed to open the URL");
open::that("https://fedistar.net/help#crash_reporting")
.expect("Failed to open the URL");
}
_ => {}
})
Expand Down
Loading