mirror of
https://git.meli.delivery/meli/meli
synced 2024-11-19 03:25:38 +00:00
ui: open MessageRfc822 attachments in new tab
This commit is contained in:
parent
f72fb069fa
commit
a866e060a1
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user