diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 737e9d15..7940d887 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -701,26 +701,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.15", - "once_cell", - "tiny-keccak", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -890,12 +870,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.1.6" @@ -1146,15 +1120,6 @@ dependencies = [ "syn 2.0.77", ] -[[package]] -name = "dlv-list" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" -dependencies = [ - "const-random", -] - [[package]] name = "document-features" version = "0.2.10" @@ -1190,11 +1155,11 @@ dependencies = [ "tauri", "tauri-build", "tauri-plugin-autostart", - "tauri-plugin-deep-link", "tauri-plugin-http", "tauri-plugin-notification", "tauri-plugin-process", "tauri-plugin-shell", + "tauri-plugin-single-instance", "tauri-plugin-window-state", "webkit2gtk", "webview2-com", @@ -3150,16 +3115,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-multimap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" -dependencies = [ - "dlv-list", - "hashbrown 0.14.5", -] - [[package]] name = "ordered-stream" version = "0.2.0" @@ -3951,17 +3906,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rust-ini" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f" -dependencies = [ - "cfg-if", - "ordered-multimap", - "trim-in-place", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -4857,26 +4801,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "tauri-plugin-deep-link" -version = "2.0.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6b5660955c91ab25365613295788ce840c4e07b810e65436720b1a194cc72c2" -dependencies = [ - "dunce", - "log", - "rust-ini", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "tauri-utils", - "thiserror", - "url", - "windows-registry", - "windows-result 0.2.0", -] - [[package]] name = "tauri-plugin-fs" version = "2.0.0-rc.1" @@ -4970,6 +4894,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "tauri-plugin-single-instance" +version = "2.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d73c92c98d44d4daba0118d905f45243dfcd6eaac82216c3382a02d17cb74cf2" +dependencies = [ + "log", + "serde", + "serde_json", + "tauri", + "thiserror", + "windows-sys 0.59.0", + "zbus", +] + [[package]] name = "tauri-plugin-window-state" version = "2.0.0-rc.2" @@ -5184,15 +5123,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tinyvec" version = "1.8.0" @@ -5451,12 +5381,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "trim-in-place" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" - [[package]] name = "try-lock" version = "0.2.5" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 35a2f62b..c948f7d0 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -27,7 +27,7 @@ serde = { version = "1", features = ["derive"] } tauri = { version = "2.0.0-rc", features = ["macos-private-api", "devtools", "tray-icon", "image-png"] } tauri-plugin-shell = "2.0.0-rc" -tauri-plugin-deep-link = "2.0.0-rc" +tauri-plugin-single-instance = "2.0.0-rc" tauri-plugin-process = "2.0.0-rc" tauri-plugin-autostart = "2.0.0-rc" tauri-plugin-notification = { version = "2.0.0-rc", features = ["win7-notifications", "windows7-compat"] } diff --git a/src-tauri/src/deep_link.rs b/src-tauri/src/deep_link.rs deleted file mode 100644 index a8cc985e..00000000 --- a/src-tauri/src/deep_link.rs +++ /dev/null @@ -1,23 +0,0 @@ -use tauri::{Listener, Manager}; - -use crate::log; - -pub fn register_deep_link_handler(app: &tauri::AppHandle) { - let handle = app.clone(); - - log!("Registering deep link handler..."); - - app.listen("deep-link://open", move |_| { - let win = handle.get_webview_window("main"); - - if win.is_none() { - return; - } - - let win = win.unwrap(); - - win.show().unwrap_or_default(); - win.set_focus().unwrap_or_default(); - win.unminimize().unwrap_or_default(); - }); -} diff --git a/src-tauri/src/functionality/window.rs b/src-tauri/src/functionality/window.rs index b0fea457..6eb5a7aa 100644 --- a/src-tauri/src/functionality/window.rs +++ b/src-tauri/src/functionality/window.rs @@ -3,7 +3,6 @@ use tauri_plugin_autostart::ManagerExt; use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use crate::config::get_config; -use crate::deep_link; use crate::log; use crate::util::window_helpers::window_zoom_level; use crate::window::blur::apply_effect; @@ -60,11 +59,6 @@ pub fn after_build(window: &tauri::WebviewWindow) { super::hotkeys::start_keybind_watcher(window); } - // Deep link registry - if !config.multi_instance.unwrap_or(false) { - deep_link::register_deep_link_handler(app); - } - // If we are opening on startup (which we know from the --startup arg), check to keep the window minimized if !startup || !config.startup_minimized.unwrap_or(false) { // Now that we are ready, and shouldn't start minimized, show the window diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index bdae1122..ccdfc273 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -30,7 +30,6 @@ use crate::{ }; mod config; -mod deep_link; mod functionality; mod gpu; mod injection; @@ -125,15 +124,13 @@ fn main() { .plugin(tauri_plugin_http::init()) .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_notification::init()) - .plugin(tauri_plugin_deep_link::init()) - .plugin(tauri_plugin_window_state::Builder::new().build()) .plugin(tauri_plugin_autostart::init( tauri_plugin_autostart::MacosLauncher::LaunchAgent, None, )) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_notification::init()) - .plugin(tauri_plugin_window_state::Builder::default().build()) + .plugin(tauri_plugin_window_state::Builder::new().build()) .invoke_handler(tauri::generate_handler![ should_disable_plugins, functionality::window::minimize, @@ -241,6 +238,25 @@ fn main() { // Set the user agent to one that enables all normal Discord features set_user_agent(&win); + // Multi-instance check + if !config.multi_instance.unwrap_or(false) { + log!("Multi-instance disabled, registering single instance plugin..."); + + app.handle().plugin(tauri_plugin_single_instance::init(move |app, _argv, _cwd| { + let win = match app.get_webview_window("main") { + Some(win) => win, + None => { + log!("No windows open with name \"main\"(???)"); + return; + }, + }; + + win.set_focus().unwrap_or_default(); + win.unminimize().unwrap_or_default(); + win.show().unwrap_or_default(); + })).unwrap_or_else(|_| log!("Failed to register single instance plugin")); + } + // If safemode is enabled, stop here if safemode { win.show().unwrap_or_default(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c4a7016b..14ff0381 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -45,16 +45,7 @@ "productName": "Dorion", "version": "5.0.1", "identifier": "com.dorion.dev", - "plugins": { - "deep-link": { - "mobile": [], - "desktop": { - "schemes": [ - "dorion" - ] - } - } - }, + "plugins": {}, "app": { "macOSPrivateApi": true, "withGlobalTauri": true,