summaryrefslogtreecommitdiff
path: root/src/view/name.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/name.rs')
-rw-r--r--src/view/name.rs27
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