diff --git a/src-tauri/src/server.rs b/src-tauri/src/server.rs index 0ca5ab6..5bfd6b8 100644 --- a/src-tauri/src/server.rs +++ b/src-tauri/src/server.rs @@ -67,12 +67,13 @@ impl Handler { // only hide the window if a) it was hidden to start with // and b) there are no other pending requests let state = self.app.state::(); + let delay = { + let config = state.config.read().unwrap(); + Duration::from_millis(config.rehide_ms) + }; + sleep(delay).await; + if !starting_visibility && state.req_count() == 0 { - let delay = { - let config = state.config.read().unwrap(); - Duration::from_millis(config.rehide_ms) - }; - sleep(delay).await; let window = self.app.get_window("main").ok_or(RequestError::NoMainWindow)?; window.hide()?; } diff --git a/src/lib/errors.js b/src/lib/errors.js new file mode 100644 index 0000000..13eef7e --- /dev/null +++ b/src/lib/errors.js @@ -0,0 +1,8 @@ +export function getRootCause(error) { + if (error.source) { + return getRootCause(error.source); + } + else { + return error; + } +}