n+l leader key for new list creation

- n is now a leader key (like t for dates)
- n + l opens Input popup to name and create a new list
- n + n opens EditTask popup to create a new task
- Popup::Input Enter now creates a list regardless of focus
- Removed immediate n behavior (list/task creation)
This commit is contained in:
Ruben Rosario
2026-06-21 18:04:37 +01:00
parent 7ebafec3c0
commit 3379cbd057
+43 -30
View File
@@ -49,6 +49,7 @@ pub struct App {
last_sync_version: u64,
editing_task_id: Option<String>,
pending_date_key: bool,
pending_new_key: bool,
auth_tx: std_mpsc::Sender<AuthEvent>,
auth_rx: std_mpsc::Receiver<AuthEvent>,
sync_tx: mpsc::Sender<SyncCommand>,
@@ -118,6 +119,7 @@ impl App {
last_sync_version: 0,
editing_task_id: None,
pending_date_key: false,
pending_new_key: false,
auth_tx,
auth_rx,
sync_tx,
@@ -246,6 +248,33 @@ impl App {
}
pub fn handle_key(&mut self, key: KeyEvent) {
if self.pending_new_key {
self.pending_new_key = false;
match key.code {
KeyCode::Char('l') | KeyCode::Char('L') => {
self.editing_task_id = None;
self.popup_input.clear();
self.popup_cursor = 0;
self.show_popup = Some(Popup::Input);
return;
}
KeyCode::Char('n') | KeyCode::Char('N') => {
if !self.lists.is_empty() {
self.editing_task_id = None;
self.popup_input.clear();
self.popup_cursor = 0;
self.popup_secondary.clear();
self.popup_secondary_cursor = 0;
self.edit_field = 0;
self.notes_scroll = 0;
self.show_popup = Some(Popup::EditTask { field: 0 });
}
return;
}
_ => {}
}
}
if let Some(ref popup) = self.show_popup.clone() {
self.handle_popup_key(key, popup);
return;
@@ -348,21 +377,7 @@ impl App {
}
KeyCode::Char('n') | KeyCode::Char('N') => {
if !self.needs_auth {
if self.focus == Focus::Tabs {
self.editing_task_id = None;
self.popup_input.clear();
self.popup_cursor = 0;
self.show_popup = Some(Popup::Input);
} else if !self.lists.is_empty() {
self.editing_task_id = None;
self.popup_input.clear();
self.popup_cursor = 0;
self.popup_secondary.clear();
self.popup_secondary_cursor = 0;
self.edit_field = 0;
self.notes_scroll = 0;
self.show_popup = Some(Popup::EditTask { field: 0 });
}
self.pending_new_key = true;
}
}
KeyCode::Char('d') | KeyCode::Char('D') => {
@@ -452,21 +467,19 @@ impl App {
KeyCode::Enter => {
let input = self.popup_input.trim().to_string();
if !input.is_empty() {
if self.focus == Focus::Tabs {
let list = TaskList {
id: uuid_v4(),
title: input,
};
self.db.insert_list(&list).ok();
self.db.push_sync(
SyncAction::Create,
&list.id,
&list.id,
&serde_json::to_string(&list).unwrap_or_default(),
).ok();
self.trigger_sync();
self.load_lists();
}
let list = TaskList {
id: uuid_v4(),
title: input,
};
self.db.insert_list(&list).ok();
self.db.push_sync(
SyncAction::Create,
&list.id,
&list.id,
&serde_json::to_string(&list).unwrap_or_default(),
).ok();
self.trigger_sync();
self.load_lists();
}
self.show_popup = None;
}