ui: make EnvelopeRename event not folder specific
And pass EnvelopeRename events to subviewsembed
parent
85d1aaaa69
commit
b6c0236d24
|
@ -646,10 +646,7 @@ impl Component for MailboxView {
|
|||
self.refresh_mailbox(context);
|
||||
self.set_dirty();
|
||||
}
|
||||
UIEvent::EnvelopeRename(ref folder_hash, ref old_hash, ref new_hash)
|
||||
if *folder_hash
|
||||
== context.accounts[self.cursor_pos.0].folders_order[self.new_cursor_pos.1] =>
|
||||
{
|
||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||
if let Some(row) = self.order.remove(old_hash) {
|
||||
self.order.insert(*new_hash, row);
|
||||
self.highlight_line(None, ((0, row), (MAX_COLS - 1, row)), row, context);
|
||||
|
@ -658,6 +655,8 @@ impl Component for MailboxView {
|
|||
} else {
|
||||
/* Listing has was updated in time before the event */
|
||||
}
|
||||
self.view
|
||||
.process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context);
|
||||
}
|
||||
UIEvent::ChangeMode(UIMode::Normal) => {
|
||||
self.dirty = true;
|
||||
|
@ -872,7 +871,7 @@ impl Component for CompactListing {
|
|||
| UIEvent::ComponentKill(_)
|
||||
| UIEvent::StartupCheck(_)
|
||||
| UIEvent::EnvelopeUpdate(_)
|
||||
| UIEvent::EnvelopeRename(_, _, _)
|
||||
| UIEvent::EnvelopeRename(_, _)
|
||||
| UIEvent::EnvelopeRemove(_) => {
|
||||
return self.views[self.cursor].process_event(event, context)
|
||||
}
|
||||
|
|
|
@ -88,23 +88,6 @@ impl MailView {
|
|||
subview: Option<Box<Component>>,
|
||||
context: &mut Context,
|
||||
) -> Self {
|
||||
let account = &mut context.accounts[coordinates.0];
|
||||
let (hash, is_seen) = {
|
||||
let envelope: &Envelope = &account.get_env(&coordinates.2);
|
||||
(envelope.hash(), envelope.is_seen())
|
||||
};
|
||||
if !is_seen {
|
||||
let folder_hash = {
|
||||
let mailbox = &mut account[coordinates.1].as_mut().unwrap();
|
||||
mailbox.folder.hash()
|
||||
};
|
||||
let op = {
|
||||
let backend = &account.backend;
|
||||
backend.operation(hash, folder_hash)
|
||||
};
|
||||
let envelope: &mut Envelope = &mut account.get_env_mut(&coordinates.2);
|
||||
envelope.set_seen(op).unwrap();
|
||||
}
|
||||
MailView {
|
||||
coordinates,
|
||||
pager,
|
||||
|
@ -304,6 +287,19 @@ impl Component for MailView {
|
|||
* arrive */
|
||||
return;
|
||||
}
|
||||
let (hash, is_seen) = {
|
||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||
(envelope.hash(), envelope.is_seen())
|
||||
};
|
||||
if !is_seen {
|
||||
let folder_hash = {
|
||||
let mailbox = &mut account[self.coordinates.1].as_mut().unwrap();
|
||||
mailbox.folder.hash()
|
||||
};
|
||||
let op = account.operation(&hash);
|
||||
let envelope: &mut Envelope = &mut account.get_env_mut(&self.coordinates.2);
|
||||
envelope.set_seen(op).unwrap();
|
||||
}
|
||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||
|
||||
if self.mode == ViewMode::Raw {
|
||||
|
@ -746,7 +742,7 @@ impl Component for MailView {
|
|||
}
|
||||
self.dirty = true;
|
||||
}
|
||||
UIEvent::EnvelopeRename(_, old_hash, new_hash) if old_hash == self.coordinates.2 => {
|
||||
UIEvent::EnvelopeRename(old_hash, new_hash) => {
|
||||
self.coordinates.2 = new_hash;
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -291,8 +291,7 @@ impl ThreadView {
|
|||
/* Box character drawing stuff */
|
||||
let mut x = 0;
|
||||
for i in 0..e.index.0 {
|
||||
let color =
|
||||
INDENTATION_COLORS[(i).wrapping_rem(INDENTATION_COLORS.len())];
|
||||
let color = INDENTATION_COLORS[(i).wrapping_rem(INDENTATION_COLORS.len())];
|
||||
change_colors(
|
||||
&mut content,
|
||||
((x, 2 * y), (x + 3, 2 * y + 1)),
|
||||
|
@ -408,6 +407,7 @@ impl ThreadView {
|
|||
|
||||
/// draw the list
|
||||
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
/* Make space on the left for the scrollbar */
|
||||
let mut upper_left = pos_inc(upper_left!(area), (1, 0));
|
||||
let bottom_right = bottom_right!(area);
|
||||
let (width, height) = self.content.size();
|
||||
|
@ -613,9 +613,11 @@ impl ThreadView {
|
|||
let i = if let Some(i) = thread_node.message() {
|
||||
i
|
||||
} else {
|
||||
threads.thread_nodes()[&thread_node.children()[0]]
|
||||
.message()
|
||||
.unwrap()
|
||||
let mut iter_ptr = thread_node.children()[0];
|
||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
||||
}
|
||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||
};
|
||||
let envelope: &Envelope = account.get_env(&i);
|
||||
|
||||
|
@ -1013,6 +1015,15 @@ impl Component for ThreadView {
|
|||
UIEvent::Resize => {
|
||||
self.set_dirty();
|
||||
}
|
||||
UIEvent::EnvelopeRename(ref old_hash, ref new_hash) => {
|
||||
for e in self.entries.iter_mut() {
|
||||
if e.msg_hash == *old_hash {
|
||||
e.msg_hash = *new_hash;
|
||||
}
|
||||
}
|
||||
self.mailview
|
||||
.process_event(&mut UIEvent::EnvelopeRename(*old_hash, *new_hash), context);
|
||||
}
|
||||
_ => {
|
||||
if self.mailview.process_event(event, context) {
|
||||
return true;
|
||||
|
|
|
@ -314,7 +314,7 @@ impl Account {
|
|||
let mailbox = mailbox!(&folder_hash, self.folders);
|
||||
mailbox.rename(old_hash, new_hash);
|
||||
self.collection.rename(old_hash, new_hash, folder_hash);
|
||||
return Some(EnvelopeRename(mailbox.folder.hash(), old_hash, new_hash));
|
||||
return Some(EnvelopeRename(old_hash, new_hash));
|
||||
}
|
||||
RefreshEventKind::Create(envelope) => {
|
||||
let env_hash = envelope.hash();
|
||||
|
|
|
@ -87,7 +87,7 @@ pub enum UIEvent {
|
|||
StartupCheck(FolderHash),
|
||||
RefreshEvent(Box<RefreshEvent>),
|
||||
EnvelopeUpdate(EnvelopeHash),
|
||||
EnvelopeRename(FolderHash, EnvelopeHash, EnvelopeHash), // folder_hash, old_hash, new_hash
|
||||
EnvelopeRename(EnvelopeHash, EnvelopeHash), // old_hash, new_hash
|
||||
EnvelopeRemove(EnvelopeHash),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue