diff options
author | jelemux <jeremias.weber@protonmail.com> | 2021-01-28 22:24:32 +0100 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2021-01-28 22:24:32 +0100 |
commit | 94a0e361e180223adf2bc9760c8810dfa3c2681f (patch) | |
tree | d29de5300d0ff0ba636f48eca8df43bb5256b49c /src/view/name.rs | |
parent | 3f0892368bcf475fdae39f24ef51b82b3013535f (diff) | |
download | wasm-card-94a0e361e180223adf2bc9760c8810dfa3c2681f.tar.gz wasm-card-94a0e361e180223adf2bc9760c8810dfa3c2681f.tar.bz2 |
use different vcard library
Diffstat (limited to 'src/view/name.rs')
-rw-r--r-- | src/view/name.rs | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/view/name.rs b/src/view/name.rs index df3fb15..bee9256 100644 --- a/src/view/name.rs +++ b/src/view/name.rs @@ -1,7 +1,7 @@ use crate::viewmodel::Error; use crate::view::WeakComponentLink; use yew::prelude::*; -use vcard::properties; +use vobject::Property; use crate::viewmodel::name::*; use crate::viewmodel::VCardPropertyInputObject; use super::VCardPropertyInputComponent; @@ -24,12 +24,12 @@ pub enum Msg { #[derive(Clone, PartialEq, Properties)] pub struct Props { - pub generated_name: Callback<Result<properties::Name,()>>, - pub generated_fn: Callback<Result<properties::FormattedName,()>>, + pub generated_name: Callback<Name>, + pub generated_fn: Callback<String>, pub weak_link: WeakComponentLink<NameView>, } -impl VCardPropertyInputComponent<properties::Name, Name> for NameView { +impl VCardPropertyInputComponent<Name> for NameView { fn get_input_object(&self) -> Name { self.value.clone() } @@ -60,23 +60,8 @@ impl Component for NameView { Msg::UpdateLastName(l) => self.value.last_name = l, Msg::UpdateSuffix(s) => self.value.suffix = s, Generate => { - match self.value.formatted_name() { - Ok(formatted_name) => self.props.generated_fn.emit(Ok(formatted_name)), - Err(error) => { - self.props.generated_fn.emit(Err(())); - self.error = Some(error); - }, - }; - match self.value.to_vcard_property() { - Ok(name) => { - self.props.generated_name.emit(Ok(name)); - return false; - }, - Err(error) => { - self.props.generated_name.emit(Err(())); - self.error = Some(error); - }, - }; + self.props.generated_fn.emit(self.value.generate_fn()); + self.props.generated_name.emit(self.value); }, }; true |