Skip to content
Snippets Groups Projects
Commit 863acd46 authored by Stephen D's avatar Stephen D
Browse files

allow saving contacts

parent ee86e722
No related branches found
No related tags found
No related merge requests found
......@@ -187,7 +187,8 @@ impl Element for Controller {
self.cur_view = View::new_contacts(*id, &self.contacts);
}
(View::ContactView(_, contact_id), KeyCode::Back) => {
(View::ContactView(cv, contact_id), KeyCode::Back) => {
self.contacts.contacts[*contact_id] = cv.contact();
self.cur_view = View::new_contact_options(*contact_id)
}
......
......@@ -69,6 +69,26 @@ impl ContactView {
selected: 0,
}
}
pub fn contact(&self) -> Contact {
if self.editable {
Contact {
callsign: self
.callsign
.get_text()
.try_into()
.unwrap_or_else(|_| self.contact.callsign.clone()),
ssid: self.ssid.get_text().parse().unwrap_or(self.contact.ssid),
name: self
.name
.get_text()
.try_into()
.unwrap_or_else(|_| self.contact.name.clone()),
}
} else {
self.contact.clone()
}
}
}
impl Element for ContactView {
......
......@@ -263,9 +263,10 @@ mod app {
}
}
let (x, y) = touchpad.get_delta_motion().unwrap();
if x != 0 || y != 0 {
ctx.shared.controller.lock(|g| g.touchpad_scroll(x, y));
if let Ok((x, y)) = touchpad.get_delta_motion() {
if x != 0 || y != 0 {
ctx.shared.controller.lock(|g| g.touchpad_scroll(x, y));
}
}
// keyboard backlight logic
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment