don't remove request from state until after re-hiding window
This commit is contained in:
parent
51fcccafa2
commit
f522674a1c
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@ -1040,7 +1040,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "creddy"
|
||||
version = "0.2.3"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"auto-launch",
|
||||
|
@ -116,6 +116,8 @@ pub enum SendResponseError {
|
||||
NotFound,
|
||||
#[error("The specified request was already closed by the client")]
|
||||
Abandoned,
|
||||
#[error("A response has already been received for the specified request")]
|
||||
Fulfilled,
|
||||
#[error("Could not renew AWS sesssion: {0}")]
|
||||
SessionRenew(#[from] GetSessionError),
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub struct AppState {
|
||||
pub config: RwLock<AppConfig>,
|
||||
pub session: RwLock<Session>,
|
||||
pub request_count: RwLock<u64>,
|
||||
pub open_requests: RwLock<HashMap<u64, Sender<ipc::Approval>>>,
|
||||
pub open_requests: RwLock<HashMap<u64, Option<Sender<ipc::Approval>>>>,
|
||||
pub pending_terminal_request: RwLock<bool>,
|
||||
pub bans: RwLock<std::collections::HashSet<Option<Client>>>,
|
||||
server: RwLock<Server>,
|
||||
@ -92,7 +92,7 @@ impl AppState {
|
||||
};
|
||||
|
||||
let mut open_requests = self.open_requests.write().await;
|
||||
open_requests.insert(*count, chan); // `count` is the request id
|
||||
open_requests.insert(*count, Some(chan)); // `count` is the request id
|
||||
*count
|
||||
}
|
||||
|
||||
@ -113,11 +113,11 @@ impl AppState {
|
||||
}
|
||||
|
||||
let mut open_requests = self.open_requests.write().await;
|
||||
let chan = open_requests
|
||||
.remove(&response.id)
|
||||
.ok_or(SendResponseError::NotFound)
|
||||
?;
|
||||
let req = open_requests
|
||||
.get_mut(&response.id)
|
||||
.ok_or(SendResponseError::NotFound)?;
|
||||
|
||||
let chan = req.take().ok_or(SendResponseError::Fulfilled)?;
|
||||
chan.send(response.approval)
|
||||
.map_err(|_e| SendResponseError::Abandoned)
|
||||
}
|
||||
|
2
todo.md
2
todo.md
@ -6,6 +6,7 @@
|
||||
* Additional hotkey configuration (approve/deny at the very least)
|
||||
* Logging
|
||||
* Icon
|
||||
* Auto-updates
|
||||
* SSH key handling
|
||||
|
||||
## Maybe
|
||||
@ -14,3 +15,4 @@
|
||||
* Rehide after terminal launch from locked
|
||||
* Generalize Request across both credentials and terminal launch?
|
||||
* Make hotkey configuration a little more tolerant of slight mistiming
|
||||
* Distinguish between request that was denied and request that was canceled (e.g. due to error)
|
||||
|
Loading…
x
Reference in New Issue
Block a user