diff options
author | jelemux <jeremias.weber@protonmail.com> | 2021-02-03 07:08:49 +0100 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2021-02-03 07:08:49 +0100 |
commit | 51bf8e89ce07864b70d7138bbc3958faf499cc67 (patch) | |
tree | 31e870adb0bcd539135059613e05a0f31e08e987 /src/view/address.rs | |
parent | 94a0e361e180223adf2bc9760c8810dfa3c2681f (diff) | |
download | wasm-card-51bf8e89ce07864b70d7138bbc3958faf499cc67.tar.gz wasm-card-51bf8e89ce07864b70d7138bbc3958faf499cc67.tar.bz2 |
now it compiles
Diffstat (limited to 'src/view/address.rs')
-rw-r--r-- | src/view/address.rs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/view/address.rs b/src/view/address.rs index 23b697a..a16d93a 100644 --- a/src/view/address.rs +++ b/src/view/address.rs @@ -1,5 +1,9 @@ +use yew::services::ConsoleService; +use yewtil::ptr::Irc; +use yewtil::ptr::Mrc; use super::WeakComponentLink; use yew::prelude::*; +use yewtil::NeqAssign; use crate::viewmodel::address::*; use crate::viewmodel::VCardPropertyInputObject; use super::VCardPropertyInputComponent; @@ -8,7 +12,7 @@ use crate::viewmodel::Error; pub struct AddressView { props: Props, - value: Address, + value: Mrc<Address>, error: Option<Error>, } @@ -28,13 +32,19 @@ pub enum Msg { #[derive(Clone, PartialEq, Properties)] pub struct Props { - pub generated: Callback<Address>, + pub generated: Callback<Irc<Address>>, pub weak_link: WeakComponentLink<AddressView>, } impl VCardPropertyInputComponent<Address> for AddressView { fn get_input_object(&self) -> Address { - self.value.clone() + match self.value.irc().try_unwrap() { + Ok(address) => address, + Err(_) => { + ConsoleService::error("Couldn't unwrap address"); + Address::new() + }, + } } fn get_title(&self) -> String { "Address".to_string() @@ -51,7 +61,7 @@ impl Component for AddressView { props.weak_link.borrow_mut().replace(link); Self { props, - value: Address::new(), + value: Mrc::new(Address::new()), error: None, } } @@ -66,19 +76,14 @@ impl Component for AddressView { Msg::UpdateCountry(c) => self.value.country = c, Msg::ToggleWork => self.value.work = !self.value.work, Msg::ToggleHome => self.value.home = !self.value.home, - Generate => { - self.props.generated.emit(self.value); + Msg::Generate => { + self.props.generated.emit(self.value.irc()); }, }; true } fn change(&mut self, props: <Self as yew::Component>::Properties) -> bool { - if self.props != props { - self.props = props; - true - } else { - false - } + self.props.neq_assign(props) } fn view(&self) -> yew::virtual_dom::VNode { let link = self.props.weak_link.borrow().clone().unwrap(); |