From fd60899f1689b95168d8d76d03dee06702c9835c Mon Sep 17 00:00:00 2001 From: Joseph Montanaro Date: Fri, 21 Apr 2023 11:18:20 -0700 Subject: [PATCH] don't re-hide when a request comes in while showing approval screen --- src-tauri/src/server.rs | 11 ++++++----- src/lib/errors.js | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 src/lib/errors.js 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; + } +}