fix error popup on startup
This commit is contained in:
@ -1,17 +1,13 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use tauri::{
|
||||
AppHandle,
|
||||
Manager,
|
||||
async_runtime as rt,
|
||||
};
|
||||
use tauri::async_runtime as rt;
|
||||
|
||||
use tauri_plugin_global_shortcut::{
|
||||
GlobalShortcutExt,
|
||||
Error as ShortcutError,
|
||||
};
|
||||
|
||||
use crate::app::APP;
|
||||
use crate::app::{self, APP};
|
||||
use crate::config::HotkeysConfig;
|
||||
use crate::errors::*;
|
||||
use crate::terminal;
|
||||
@ -29,36 +25,18 @@ pub fn exec_shortcut(action: ShortcutAction) {
|
||||
ShortcutAction::LaunchTerminal => launch_terminal(),
|
||||
ShortcutAction::ShowWindow => {
|
||||
let app = APP.get().unwrap();
|
||||
show_window(app);
|
||||
app::show_main_window(app)
|
||||
.error_popup("Failed to show Creddy");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn show_window(app: &AppHandle) {
|
||||
let handle = app.clone();
|
||||
rt::spawn(async move {
|
||||
handle.get_webview_window("main")
|
||||
.ok_or("Couldn't find application main window")
|
||||
.error_popup_passthrough("Failed to show window").await?
|
||||
.show()
|
||||
.error_popup("Failed to show window").await;
|
||||
Ok::<(), ()>(())
|
||||
});
|
||||
|
||||
// app.get_webview_window("main") // Option<Window>
|
||||
// .ok_or("Couldn't find application main window") // Result<Window, &'static str>
|
||||
// .map(|w| w.show().error_popup("Failed to show window"))
|
||||
// .error_popup("Failed to show window");
|
||||
}
|
||||
|
||||
|
||||
fn launch_terminal() {
|
||||
rt::spawn(async {
|
||||
terminal::launch(false)
|
||||
.await
|
||||
.error_popup("Failed to launch terminal")
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
@ -74,7 +52,9 @@ pub fn register_hotkeys(hotkeys: &HotkeysConfig) -> Result<(), ShortcutError> {
|
||||
if hotkeys.show_window.enabled {
|
||||
shortcuts.on_shortcut(
|
||||
hotkeys.show_window.keys.as_str(),
|
||||
|app, _shortcut, _event| show_window(app)
|
||||
|app, _shortcut, _event| {
|
||||
app::show_main_window(app).error_popup("Failed to show Creddy")
|
||||
}
|
||||
)?;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user