Browse Source

ui: open MessageRfc822 attachments in new tab

tags/pre-alpha-0.3.0
Manos Pitsidianakis 2 years ago
parent
commit
a866e060a1
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 2
      ui/src/components.rs
  2. 11
      ui/src/components/contacts/contact_list.rs
  3. 2
      ui/src/components/mail/accounts.rs
  4. 2
      ui/src/components/mail/compose.rs
  5. 15
      ui/src/components/mail/view.rs
  6. 8
      ui/src/components/mail/view/envelope.rs
  7. 4
      ui/src/components/utilities.rs
  8. 2
      ui/src/execute/actions.rs

2
ui/src/components.rs

@ -93,7 +93,7 @@ pub trait Component: Display + Debug + Send {
true
}
fn set_dirty(&mut self);
fn kill(&mut self, _id: ComponentId) {}
fn kill(&mut self, _id: ComponentId, _context: &mut Context) {}
fn set_id(&mut self, _id: ComponentId) {}
fn id(&self) -> ComponentId;

11
ui/src/components/contacts/contact_list.rs

@ -8,7 +8,6 @@ const MAX_COLS: usize = 500;
enum ViewMode {
List,
View(CardId),
Close(Uuid),
}
#[derive(Debug)]
@ -158,11 +157,6 @@ impl ContactList {
impl Component for ContactList {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
if let ViewMode::Close(u) = self.mode {
context.replies.push_back(UIEvent::Action(Tab(Kill(u))));
return;
}
if let Some(mgr) = self.view.as_mut() {
mgr.draw(grid, area, context);
return;
@ -289,8 +283,9 @@ impl Component for ContactList {
self.dirty = true;
}
fn kill(&mut self, uuid: Uuid) {
self.mode = ViewMode::Close(uuid);
fn kill(&mut self, uuid: Uuid, context: &mut Context) {
debug_assert!(uuid == self.id);
context.replies.push_back(UIEvent::Action(Tab(Kill(uuid))));
}
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let mut map = self

2
ui/src/components/mail/accounts.rs

@ -65,7 +65,7 @@ impl Component for AccountsPanel {
UIEvent::Input(Key::Char('\n')) => {
context
.replies
.push_back(UIEvent::Action(Tab(TabOpen(Some(Box::new(
.push_back(UIEvent::Action(Tab(New(Some(Box::new(
ContactList::for_account(self.cursor),
))))));
return true;

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

@ -713,7 +713,7 @@ impl Component for Composer {
}
}
fn kill(&mut self, uuid: Uuid) {
fn kill(&mut self, uuid: Uuid, _context: &mut Context) {
self.mode = ViewMode::Discard(uuid);
}

15
ui/src/components/mail/view.rs

@ -731,15 +731,16 @@ impl Component for MailView {
if let Some(u) = envelope.body(op).attachments().get(lidx) {
match u.content_type() {
ContentType::MessageRfc822 => {
self.mode = ViewMode::Subview;
match EnvelopeWrapper::new(u.raw().to_vec()) {
Ok(wrapper) => {
self.subview = Some(Box::new(EnvelopeView::new(
wrapper,
None,
None,
self.coordinates.0,
)));
context.replies.push_back(UIEvent::Action(Tab(New(Some(
Box::new(EnvelopeView::new(
wrapper,
None,
None,
self.coordinates.0,
)),
)))));
}
Err(e) => {
context.replies.push_back(UIEvent::StatusEvent(

8
ui/src/components/mail/view/envelope.rs

@ -555,6 +555,14 @@ impl Component for EnvelopeView {
fn id(&self) -> ComponentId {
self.id
}
fn kill(&mut self, id: ComponentId, context: &mut Context) {
debug_assert!(self.id == id);
context
.replies
.push_back(UIEvent::Action(Tab(Kill(self.id))));
}
fn set_id(&mut self, id: ComponentId) {
self.id = id;
}

4
ui/src/components/utilities.rs

@ -1345,7 +1345,7 @@ impl Component for Tabbed {
self.children[self.cursor_pos].set_dirty();
return true;
}
UIEvent::Action(Tab(TabOpen(ref mut e))) if e.is_some() => {
UIEvent::Action(Tab(New(ref mut e))) if e.is_some() => {
self.add_component(e.take().unwrap());
self.cursor_pos = self.children.len() - 1;
self.children[self.cursor_pos].set_dirty();
@ -1356,7 +1356,7 @@ impl Component for Tabbed {
return true;
}
let id = self.children[self.cursor_pos].id();
self.children[self.cursor_pos].kill(id);
self.children[self.cursor_pos].kill(id, context);
self.set_dirty();
return true;
}

2
ui/src/execute/actions.rs

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

Loading…
Cancel
Save