contacts/editor: fix crash on saving contact

Oops...

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
This commit is contained in:
Manos Pitsidianakis 2024-11-26 17:52:44 +02:00
parent 13e917d97b
commit 8c176d3840
No known key found for this signature in database
GPG key ID: 7729C7707F7E09D0
2 changed files with 4 additions and 8 deletions

View file

@ -209,7 +209,7 @@ impl Component for ContactManager {
match self.form.buttons_result() {
None => {}
Some(FormButtonAction::Accept) => {
let fields = std::mem::take(&mut self.form).collect().unwrap();
let fields = std::mem::take(&mut self.form).collect();
let fields: IndexMap<String, String> = fields
.into_iter()
.map(|(s, v)| {
@ -237,7 +237,7 @@ impl Component for ContactManager {
}
Some(FormButtonAction::Other("Export")) => {
let card = if self.has_changes {
let fields = self.form.clone().collect().unwrap();
let fields = self.form.clone().collect();
let fields: IndexMap<String, String> = fields
.into_iter()
.map(|(s, v)| {

View file

@ -352,12 +352,8 @@ impl<T: 'static + std::fmt::Debug + Copy + Default + Send + Sync> FormWidget<T>
&mut self.fields
}
pub fn collect(self) -> Option<HashMap<Cow<'static, str>, Field>> {
if self.buttons.result.is_some() {
Some(self.fields)
} else {
None
}
pub fn collect(self) -> HashMap<Cow<'static, str>, Field> {
self.fields
}
pub fn buttons_result(&mut self) -> Option<T> {