summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-12-08 10:57:36 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-12-08 11:25:54 +0200
commit0eaf17871a79278d56bac0ba83cdae85f8e5ce03 (patch)
tree3aebf024a8bce3079eb915316437272bc6751b8f /ui/src/components
parentf632bc4c08b7a9d4630b34c446863f2126716316 (diff)
melib: add set_tags command in BackendOp
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/mail/listing.rs45
-rw-r--r--ui/src/components/mail/listing/conversations.rs3
2 files changed, 18 insertions, 30 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index ad53231a..4b737087 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -105,42 +105,27 @@ pub trait MailListingTrait: ListingTrait {
continue;
}
ListingAction::Tag(Remove(ref tag_str)) => {
- use std::collections::hash_map::DefaultHasher;
- use std::hash::Hasher;
- let h = {
- let mut hasher = DefaultHasher::new();
- hasher.write(tag_str.as_bytes());
- hasher.finish()
- };
let backend_lck = account.backend.write().unwrap();
- if let Some(t) = backend_lck.tags() {
- let mut tags_lck = t.write().unwrap();
- if !tags_lck.contains_key(&h) {
- tags_lck.insert(h, tag_str.to_string());
- }
- if let Some(pos) = envelope.labels().iter().position(|&el| el == h) {
- envelope.labels_mut().remove(pos);
- }
- } else {
+ let mut op = backend_lck.operation(envelope.hash());
+ if let Err(err) = op.set_tag(&mut envelope, tag_str.to_string(), false) {
+ context.replies.push_back(UIEvent::Notification(
+ Some("Could not set tag.".to_string()),
+ err.to_string(),
+ Some(NotificationType::ERROR),
+ ));
return;
}
}
ListingAction::Tag(Add(ref tag_str)) => {
- use std::collections::hash_map::DefaultHasher;
- use std::hash::Hasher;
- let h = {
- let mut hasher = DefaultHasher::new();
- hasher.write(tag_str.as_bytes());
- hasher.finish()
- };
let backend_lck = account.backend.write().unwrap();
- if let Some(t) = backend_lck.tags() {
- let mut tags_lck = t.write().unwrap();
- if !tags_lck.contains_key(&h) {
- tags_lck.insert(h, tag_str.to_string());
- }
- envelope.labels_mut().push(h);
- } else {
+ let mut op = backend_lck.operation(envelope.hash());
+
+ if let Err(err) = op.set_tag(&mut envelope, tag_str.to_string(), true) {
+ context.replies.push_back(UIEvent::Notification(
+ Some("Could not set tag.".to_string()),
+ err.to_string(),
+ Some(NotificationType::ERROR),
+ ));
return;
}
}
diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs
index b8019871..0ba9306d 100644
--- a/ui/src/components/mail/listing/conversations.rs
+++ b/ui/src/components/mail/listing/conversations.rs
@@ -1131,6 +1131,9 @@ impl Component for ConversationsListing {
area,
Some(get_x(upper_left)),
);
+ for c in grid.row_iter((x, get_x(bottom_right)), y) {
+ grid[c] = Cell::default();
+ }
clear_area(grid, ((x, y), set_y(bottom_right, y)));
context
.dirty_areas