Skip to content

Commit 1207217

Browse files
committed
compose: s/Option<AccountHash>/AccountHash in EditAttachments
Signed-off-by: Manos Pitsidianakis <[email protected]>
1 parent 0946703 commit 1207217

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

meli/src/mail/compose.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub struct Composer {
130130
enum ViewMode {
131131
Discard(ComponentId, UIDialog<char>),
132132
EditAttachments {
133-
widget: EditAttachments,
133+
widget: Box<EditAttachments>,
134134
},
135135
Edit,
136136
EmbeddedPty,
@@ -1927,7 +1927,7 @@ impl Component for Composer {
19271927
&& shortcut!(key == shortcuts[Shortcuts::COMPOSING]["edit"]) =>
19281928
{
19291929
self.mode = ViewMode::EditAttachments {
1930-
widget: EditAttachments::new(Some(self.account_hash)),
1930+
widget: Box::new(EditAttachments::new(self.account_hash)),
19311931
};
19321932
self.set_dirty(true);
19331933

@@ -2528,6 +2528,8 @@ impl Component for Composer {
25282528
fn shortcuts(&self, context: &Context) -> ShortcutMaps {
25292529
let mut map = if self.mode.is_edit() {
25302530
self.pager.shortcuts(context)
2531+
} else if let ViewMode::EditAttachments { ref widget } = self.mode {
2532+
widget.shortcuts(context)
25312533
} else {
25322534
Default::default()
25332535
};

meli/src/mail/compose/edit_attachments.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum EditAttachmentMode {
4040
#[derive(Debug)]
4141
pub struct EditAttachments {
4242
/// For shortcut setting retrieval.
43-
pub account_hash: Option<AccountHash>,
43+
pub account_hash: AccountHash,
4444
pub mode: EditAttachmentMode,
4545
pub buttons: ButtonWidget<FormButtonAction>,
4646
pub cursor: EditAttachmentCursor,
@@ -49,7 +49,7 @@ pub struct EditAttachments {
4949
}
5050

5151
impl EditAttachments {
52-
pub fn new(account_hash: Option<AccountHash>) -> Self {
52+
pub fn new(account_hash: AccountHash) -> Self {
5353
//ButtonWidget::new(("Add".into(), FormButtonAction::Other("add")));
5454
let mut buttons = ButtonWidget::new(("Go Back".into(), FormButtonAction::Cancel));
5555
buttons.set_focus(true);
@@ -63,6 +63,16 @@ impl EditAttachments {
6363
id: ComponentId::default(),
6464
}
6565
}
66+
67+
pub fn shortcuts(&self, context: &Context) -> ShortcutMaps {
68+
let mut map = self.buttons.shortcuts(context);
69+
70+
let our_map: ShortcutMap =
71+
account_settings!(context[self.account_hash].shortcuts.composing).key_values();
72+
map.insert(Shortcuts::COMPOSING, our_map);
73+
74+
map
75+
}
6676
}
6777

6878
impl EditAttachmentsRefMut<'_, '_> {
@@ -319,16 +329,7 @@ impl Component for EditAttachmentsRefMut<'_, '_> {
319329
fn kill(&mut self, _uuid: ComponentId, _context: &mut Context) {}
320330

321331
fn shortcuts(&self, context: &Context) -> ShortcutMaps {
322-
let mut map = ShortcutMaps::default();
323-
324-
let our_map: ShortcutMap = self
325-
.inner
326-
.account_hash
327-
.map(|acc| account_settings!(context[acc].shortcuts.composing).key_values())
328-
.unwrap_or_else(|| context.settings.shortcuts.composing.key_values());
329-
map.insert(Shortcuts::COMPOSING, our_map);
330-
331-
map
332+
self.inner.shortcuts(context)
332333
}
333334

334335
fn id(&self) -> ComponentId {

0 commit comments

Comments
 (0)