소스 검색

contacts/editor: fix crash on saving contact

Oops...

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
Manos Pitsidianakis 7 달 전
부모
커밋
8c176d38
2개의 변경된 파일4개의 추가작업 그리고 8개의 파일을 삭제
  1. 2 2
      meli/src/contacts/editor.rs
  2. 2 6
      meli/src/utilities/widgets.rs

+ 2 - 2
meli/src/contacts/editor.rs

@@ -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)| {

+ 2 - 6
meli/src/utilities/widgets.rs

@@ -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> {