Skip to content

Commit

Permalink
fix: window flashes white for a millisecond before load. tauri-apps/t…
Browse files Browse the repository at this point in the history
  • Loading branch information
THEGOLDENPRO committed May 15, 2024
1 parent 388d476 commit 21f4450
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::Manager;
use std::path::PathBuf;
use rfd::AsyncFileDialog;
use image::ImageFormat;
Expand All @@ -19,6 +20,11 @@ async fn select_image() {
set_image(&pick_image().await.to_str().unwrap().to_string());
}

#[tauri::command]
fn show_window(window: tauri::Window) {
window.get_window("main").unwrap().show().unwrap();
}

fn main() {
tauri::Builder::default()
.setup(|app| {
Expand All @@ -41,7 +47,7 @@ fn main() {

Ok(())
})
.invoke_handler(tauri::generate_handler![get_image, select_image])
.invoke_handler(tauri::generate_handler![get_image, select_image, show_window])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Expand Down
1 change: 1 addition & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
},
"windows": [
{
"visible": false,
"fullscreen": false,
"height": 600,
"resizable": true,
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Home() {

const [image, setImage] = useState<Image | null>(null);

console.log("jeff");
useEffect(() => {invoke("show_window");}, []);

function load_image() {
if (image_load_called.current == false && image == null && no_image_available == false) {
Expand Down

0 comments on commit 21f4450

Please sign in to comment.