From 59f4b2ef167d64013c1f26ae92a45e4de0d13c65 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Sat, 16 Mar 2024 13:16:29 +0100 Subject: [PATCH] refactor: Remove Rust window handler and migrate to the JS ones --- src-tauri/src/main.rs | 13 +------------ src/ui/components/native/WindowFrame.tsx | 3 ++- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index da672378..1ff6798d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -4,28 +4,17 @@ use std::error::Error; use polyfrost_launcher::auth; -use tauri::{App, Manager}; +use tauri::App; fn main() { tauri::Builder::default() .plugin(tauri_plugin_shell::init()) .plugin(auth::init()) .setup(setup) - .on_window_event(window_handler) .run(tauri::generate_context!()) .expect("error while running tauri application"); } -fn window_handler(window: &tauri::Window, event: &tauri::WindowEvent) { - match event { - tauri::WindowEvent::CloseRequested { api, .. } => { - api.prevent_close(); - let _ = window.emit("handle_window_close_request", ()); - } - _ => {} - } -} - fn setup(_: &mut App) -> Result<(), Box> { Ok(()) } diff --git a/src/ui/components/native/WindowFrame.tsx b/src/ui/components/native/WindowFrame.tsx index e6b3d065..fa81cede 100644 --- a/src/ui/components/native/WindowFrame.tsx +++ b/src/ui/components/native/WindowFrame.tsx @@ -27,7 +27,8 @@ function WindowFrame() { const minimize = () => Window.getCurrent().minimize(); const quit = () => Window.getCurrent().destroy(); - Window.getCurrent().listen('handle_window_close_request', () => { + Window.getCurrent().onCloseRequested((event) => { + event.preventDefault(); setModalVisible(true); });