ui: make Composer account specific

embed
Manos Pitsidianakis 2019-04-06 00:43:50 +03:00
parent cfb7dcec64
commit 4bf1f6b9c9
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
7 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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