Reload Endpoint Reload Keybind Reload Logic
Remove TU Endpoint
This commit is contained in:
parent
fe0b3f0315
commit
7bf90a3699
10 changed files with 385 additions and 201 deletions
|
|
@ -1,11 +1,16 @@
|
|||
use crate::{SHUTDOWN, gui::tui::UNIQUE, util::config_util::CONFIG};
|
||||
use crate::{ACTIVE_TASKS, RELOAD, SHUTDOWN, gui::tui::UNIQUE, util::config_util::CONFIG};
|
||||
use crossterm::event::{KeyEvent, KeyModifiers};
|
||||
use ratatui::crossterm::event::{Event, KeyCode, read};
|
||||
use tokio::{self};
|
||||
use tokio_util::sync::WaitForCancellationFutureOwned;
|
||||
|
||||
pub fn setup_input_handler() {
|
||||
tokio::spawn(async move {
|
||||
{
|
||||
ACTIVE_TASKS
|
||||
.lock()
|
||||
.unwrap()
|
||||
.push("Input Handler".to_string());
|
||||
}
|
||||
while let Ok(event) = read() {
|
||||
if *SHUTDOWN.read().await {
|
||||
break;
|
||||
|
|
@ -13,6 +18,15 @@ pub fn setup_input_handler() {
|
|||
if let Event::Key(key) = event {
|
||||
handle_input(key).await;
|
||||
}
|
||||
if *SHUTDOWN.read().await {
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
ACTIVE_TASKS
|
||||
.lock()
|
||||
.unwrap()
|
||||
.retain(|t| !t.eq(&"Input Handler".to_string()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -22,6 +36,14 @@ pub async fn handle_input(key: KeyEvent) {
|
|||
(KeyCode::Char('c'), KeyModifiers::CONTROL) => {
|
||||
*SHUTDOWN.write().await = true;
|
||||
}
|
||||
(KeyCode::Char('r'), KeyModifiers::CONTROL) => {
|
||||
{
|
||||
*RELOAD.write().await = true;
|
||||
}
|
||||
{
|
||||
*SHUTDOWN.write().await = true;
|
||||
}
|
||||
}
|
||||
(KeyCode::Backspace, KeyModifiers::NONE) => {
|
||||
let password: String = {
|
||||
let cfg = CONFIG.read().await;
|
||||
|
|
|
|||
Loading…
Reference in a new issue