Browse Source

ui: make Composer account specific

tags/pre-alpha-0.0
Manos Pitsidianakis 3 years ago
parent
commit
4bf1f6b9c9
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 2
      melib/src/mailbox/email/compose.rs
  2. 6
      ui/src/components/mail/compose.rs
  3. 2
      ui/src/components/mail/listing/compact.rs
  4. 2
      ui/src/components/mail/listing/plain.rs
  5. 2
      ui/src/components/mail/listing/thread.rs
  6. 4
      ui/src/components/utilities.rs
  7. 2
      ui/src/execute/actions.rs

2
melib/src/mailbox/email/compose.rs

@ -12,7 +12,7 @@ mod random;
use super::parser;
use fnv::FnvHashMap;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub struct Draft {
// FIXME: Preserve header order
// FIXME: Validate headers, allow custom ones

6
ui/src/components/mail/compose.rs

@ -112,6 +112,12 @@ impl fmt::Display for Composer {
}
impl Composer {
pub fn new(account_cursor: usize) -> Self {
Composer {
account_cursor,
..Default::default()
}
}
/*
* coordinates: (account index, mailbox index, root set thread_node index)
* msg: index of message we reply to in thread_nodes

2
ui/src/components/mail/listing/compact.rs

@ -530,7 +530,7 @@ impl Component for CompactListing {
UIEventType::Input(Key::Char('m')) if !self.unfocused => {
context.replies.push_back(UIEvent {
id: 0,
event_type: UIEventType::Action(Tab(NewDraft)),
event_type: UIEventType::Action(Tab(NewDraft(self.cursor_pos.0))),
});
return true;
}

2
ui/src/components/mail/listing/plain.rs

@ -437,7 +437,7 @@ impl Component for PlainListing {
UIEventType::Input(Key::Char('m')) if !self.unfocused => {
context.replies.push_back(UIEvent {
id: 0,
event_type: UIEventType::Action(Tab(NewDraft)),
event_type: UIEventType::Action(Tab(NewDraft(self.cursor_pos.0))),
});
return true;
}

2
ui/src/components/mail/listing/thread.rs

@ -599,7 +599,7 @@ impl Component for ThreadListing {
UIEventType::Input(Key::Char('m')) if !self.unfocused => {
context.replies.push_back(UIEvent {
id: 0,
event_type: UIEventType::Action(Tab(NewDraft)),
event_type: UIEventType::Action(Tab(NewDraft(self.cursor_pos.0))),
});
return true;
}

4
ui/src/components/utilities.rs

@ -999,8 +999,8 @@ impl Component for Tabbed {
self.set_dirty();
return true;
}
UIEventType::Action(Tab(NewDraft)) => {
self.add_component(Box::new(Composer::default()));
UIEventType::Action(Tab(NewDraft(account_idx))) => {
self.add_component(Box::new(Composer::new(account_idx)));
self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty();
return true;

2
ui/src/execute/actions.rs

@ -39,7 +39,7 @@ pub enum ListingAction {
#[derive(Debug)]
pub enum TabAction {
TabOpen(Option<Box<Component>>),
NewDraft,
NewDraft(usize),
Reply((usize, usize, usize), usize), // thread coordinates (account, mailbox, root_set idx) and message idx
Close,
Edit((usize, usize, usize), usize), // thread coordinates (account, mailbox, root_set idx) and message idx

Loading…
Cancel
Save