diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 047f8a4d..e002c249 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -707,11 +707,35 @@ impl Component for MailView { let shortcuts = &self.get_shortcuts(context)[MailView::DESCRIPTION]; match *event { + UIEvent::Input(ref k) if *k == shortcuts["reply"] => { + let account = &context.accounts[self.coordinates.0]; + let folder_hash = account[self.coordinates.1].unwrap().folder.hash(); + let envelope: EnvelopeRef = account.collection.get_env(self.coordinates.2); + let thread_hash = envelope.thread(); + let threads = &account.collection.threads[&folder_hash]; + let root_thread_hash = melib::find_root_hash(&threads.thread_nodes, thread_hash); + let root_idx = threads + .root_iter() + .position(|t| t == root_thread_hash) + .unwrap(); + context.replies.push_back(UIEvent::Action(Tab(Reply( + (self.coordinates.0, self.coordinates.1, root_idx), + thread_hash, + )))); + return true; + } + UIEvent::Input(ref k) if *k == shortcuts["edit"] => { + context.replies.push_back(UIEvent::Action(Tab(Edit( + self.coordinates.0, + self.coordinates.2, + )))); + return true; + } UIEvent::Input(ref key) if !self.mode.is_contact_selector() && *key == shortcuts["add_addresses_to_contacts"] => { - let account = &mut context.accounts[self.coordinates.0]; + let account = &context.accounts[self.coordinates.0]; let envelope: EnvelopeRef = account.collection.get_env(self.coordinates.2); let mut entries = Vec::new(); @@ -1296,6 +1320,8 @@ impl Component for MailView { let mut our_map = FnvHashMap::with_capacity_and_hasher(4, Default::default()); our_map.insert("add_addresses_to_contacts", Key::Char('c')); our_map.insert("view_raw_source", Key::Alt('r')); + our_map.insert("reply", Key::Char('R')); + our_map.insert("edit", Key::Char('e')); if self.mode.is_attachment() || self.mode == ViewMode::Subview || self.mode == ViewMode::Raw diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index b993b7e7..dd6384e1 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -950,41 +950,6 @@ impl Component for ThreadView { let shortcuts = &self.get_shortcuts(context)[ThreadView::DESCRIPTION]; match *event { - UIEvent::Input(Key::Char('R')) => { - context.replies.push_back(UIEvent::Action(Tab(Reply( - self.coordinates, - self.entries[self.expanded_pos].index.1, - )))); - return true; - } - UIEvent::Input(Key::Char('e')) => { - { - let account = &context.accounts[self.coordinates.0]; - let mailbox = &account[self.coordinates.1].unwrap(); - let threads = &account.collection.threads[&mailbox.folder.hash()]; - let thread_node = - &threads.thread_nodes()[&threads.root_set(self.coordinates.2)]; - let i = if let Some(i) = thread_node.message() { - i - } else { - threads.thread_nodes()[&thread_node.children()[0]] - .message() - .unwrap() - }; - let envelope: EnvelopeRef = account.collection.get_env(i); - let op = account.operation(envelope.hash()); - debug!( - "sending action edit for {}, {}", - envelope.message_id(), - op.description() - ); - context.replies.push_back(UIEvent::Action(Tab(Edit( - self.coordinates.0, - envelope.hash(), - )))); - } - return true; - } UIEvent::Input(Key::Up) => { if self.cursor_pos > 0 { self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1); @@ -1111,7 +1076,6 @@ impl Component for ThreadView { map.insert( ThreadView::DESCRIPTION.to_string(), [ - ("reply", Key::Char('R')), ("reverse thread order", Key::Ctrl('r')), ("toggle_mailview", Key::Char('p')), ("toggle_subthread visibility", Key::Char('h')),