ui: improve contact additions from mail view
parent
37716c85df
commit
5d9af8e32b
|
@ -149,32 +149,32 @@ impl Card {
|
||||||
pub fn set_id(&mut self, new: Uuid) {
|
pub fn set_id(&mut self, new: Uuid) {
|
||||||
self.id = new;
|
self.id = new;
|
||||||
}
|
}
|
||||||
pub fn set_title(&mut self, new: &str) {
|
pub fn set_title(&mut self, new: String) {
|
||||||
self.title = new.to_string();
|
self.title = new;
|
||||||
}
|
}
|
||||||
pub fn set_firstname(&mut self, new: &str) {
|
pub fn set_firstname(&mut self, new: String) {
|
||||||
self.firstname = new.to_string();
|
self.firstname = new;
|
||||||
}
|
}
|
||||||
pub fn set_lastname(&mut self, new: &str) {
|
pub fn set_lastname(&mut self, new: String) {
|
||||||
self.lastname = new.to_string();
|
self.lastname = new;
|
||||||
}
|
}
|
||||||
pub fn set_additionalname(&mut self, new: &str) {
|
pub fn set_additionalname(&mut self, new: String) {
|
||||||
self.additionalname = new.to_string();
|
self.additionalname = new;
|
||||||
}
|
}
|
||||||
pub fn set_name_prefix(&mut self, new: &str) {
|
pub fn set_name_prefix(&mut self, new: String) {
|
||||||
self.name_prefix = new.to_string();
|
self.name_prefix = new;
|
||||||
}
|
}
|
||||||
pub fn set_name_suffix(&mut self, new: &str) {
|
pub fn set_name_suffix(&mut self, new: String) {
|
||||||
self.name_suffix = new.to_string();
|
self.name_suffix = new;
|
||||||
}
|
}
|
||||||
pub fn set_email(&mut self, new: &str) {
|
pub fn set_email(&mut self, new: String) {
|
||||||
self.email = new.to_string();
|
self.email = new;
|
||||||
}
|
}
|
||||||
pub fn set_url(&mut self, new: &str) {
|
pub fn set_url(&mut self, new: String) {
|
||||||
self.url = new.to_string();
|
self.url = new;
|
||||||
}
|
}
|
||||||
pub fn set_key(&mut self, new: &str) {
|
pub fn set_key(&mut self, new: String) {
|
||||||
self.key = new.to_string();
|
self.key = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_extra_property(&mut self, key: &str, value: String) {
|
pub fn set_extra_property(&mut self, key: &str, value: String) {
|
||||||
|
|
|
@ -394,53 +394,54 @@ impl Component for MailView {
|
||||||
|
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Char('c')) => {
|
UIEventType::Input(Key::Char('c')) => {
|
||||||
/*
|
|
||||||
let mut new_card: Card = Card::new();
|
|
||||||
new_card.set_email(&envelope.from()[0].get_email());
|
|
||||||
new_card.set_firstname(&envelope.from()[0].get_display_name());
|
|
||||||
|
|
||||||
if cfg!(feature = "debug_log") {
|
|
||||||
eprintln!("{:?}", new_card);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
if let ViewMode::ContactSelector(_) = self.mode {
|
if let ViewMode::ContactSelector(_) = self.mode {
|
||||||
if let ViewMode::ContactSelector(s) =
|
if let ViewMode::ContactSelector(s) =
|
||||||
std::mem::replace(&mut self.mode, ViewMode::Normal)
|
std::mem::replace(&mut self.mode, ViewMode::Normal)
|
||||||
{
|
{
|
||||||
for c in s.collect() {
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
let mut new_card: Card = Card::new();
|
let mut results = Vec::new();
|
||||||
let email = String::from_utf8(c).unwrap();
|
{
|
||||||
new_card.set_email(&email);
|
let mailbox = &account[self.coordinates.1]
|
||||||
new_card.set_firstname("");
|
.as_ref()
|
||||||
context.accounts[self.coordinates.0]
|
.unwrap();
|
||||||
.address_book
|
let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
|
||||||
.add_card(new_card);
|
for c in s.collect() {
|
||||||
|
let c = usize::from_ne_bytes({
|
||||||
|
[c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]]
|
||||||
|
});
|
||||||
|
for (idx, env) in envelope.from().iter().chain(envelope.to().iter()).enumerate() {
|
||||||
|
if idx != c {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut new_card: Card = Card::new();
|
||||||
|
new_card.set_email(env.get_email());
|
||||||
|
new_card.set_lastname(env.get_display_name());
|
||||||
|
results.push(new_card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for c in results {
|
||||||
|
account.address_book.add_card(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//if cfg!(feature = "debug_log") {
|
|
||||||
//eprintln!("{:?}", s.collect());
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let accounts = &context.accounts;
|
let accounts = &context.accounts;
|
||||||
let mailbox = &accounts[self.coordinates.0][self.coordinates.1]
|
let mailbox = &accounts[self.coordinates.0][self.coordinates.1]
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
|
let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
|
||||||
|
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
entries.push((
|
for (idx, env) in envelope.from().iter().chain(envelope.to().iter()).enumerate() {
|
||||||
envelope.from()[0].get_email().into_bytes(),
|
entries.push((
|
||||||
format!("{}", envelope.from()[0]),
|
idx.to_ne_bytes().to_vec(),
|
||||||
));
|
format!("{}", env),
|
||||||
entries.push((
|
));
|
||||||
envelope.to()[0].get_email().into_bytes(),
|
}
|
||||||
format!("{}", envelope.to()[0]),
|
|
||||||
));
|
|
||||||
self.mode = ViewMode::ContactSelector(Selector::new(entries, true));
|
self.mode = ViewMode::ContactSelector(Selector::new(entries, true));
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
//context.accounts.context(self.coordinates.0).address_book.add_card(new_card);
|
|
||||||
}
|
}
|
||||||
UIEventType::Input(Key::Esc) | UIEventType::Input(Key::Alt('')) => {
|
UIEventType::Input(Key::Esc) | UIEventType::Input(Key::Alt('')) => {
|
||||||
self.cmd_buf.clear();
|
self.cmd_buf.clear();
|
||||||
|
|
Loading…
Reference in New Issue