diff --git a/src/frontend/configuration.rs b/src/frontend/configuration.rs index 2a208ae2..1c37151f 100644 --- a/src/frontend/configuration.rs +++ b/src/frontend/configuration.rs @@ -1,9 +1,7 @@ use crate::backend::config::{Farm, RawConfig}; use bytesize::ByteSize; use gtk::prelude::*; -use relm4::component::{AsyncComponent, AsyncComponentParts}; use relm4::prelude::*; -use relm4::AsyncComponentSender; use relm4_components::open_dialog::{ OpenDialog, OpenDialogMsg, OpenDialogResponse, OpenDialogSettings, }; @@ -97,8 +95,8 @@ pub struct ConfigurationView { open_dialog: Controller, } -#[relm4::component(async, pub)] -impl AsyncComponent for ConfigurationView { +#[relm4::component(pub)] +impl Component for ConfigurationView { type Init = (); type Input = ConfigurationInput; type Output = ConfigurationOutput; @@ -325,15 +323,13 @@ impl AsyncComponent for ConfigurationView { connect_clicked => ConfigurationInput::Start, set_margin_top: 20, #[watch] - set_sensitive: { - // TODO + set_sensitive: model.reward_address.valid() && model.node_path.valid() && !model.farms.is_empty() && model.farms.iter().all(|farm| { farm.path.valid() && farm.size.valid() - }) - }, + }), gtk::Label { set_label: "Start", @@ -346,13 +342,13 @@ impl AsyncComponent for ConfigurationView { } } - async fn init( + fn init( _init: Self::Init, - root: Self::Root, - sender: AsyncComponentSender, - ) -> AsyncComponentParts { + root: &Self::Root, + sender: ComponentSender, + ) -> ComponentParts { let open_dialog = OpenDialog::builder() - .transient_for_native(&root) + .transient_for_native(root) .launch(OpenDialogSettings { folder_mode: true, accept_label: "Select".to_string(), @@ -373,25 +369,16 @@ impl AsyncComponent for ConfigurationView { let widgets = view_output!(); - AsyncComponentParts { model, widgets } + ComponentParts { model, widgets } } - async fn update( - &mut self, - input: Self::Input, - sender: AsyncComponentSender, - _root: &Self::Root, - ) { - self.process_input(input, sender).await; + fn update(&mut self, input: Self::Input, sender: ComponentSender, _root: &Self::Root) { + self.process_input(input, sender); } } impl ConfigurationView { - async fn process_input( - &mut self, - input: ConfigurationInput, - sender: AsyncComponentSender, - ) { + fn process_input(&mut self, input: ConfigurationInput, sender: ComponentSender) { match input { ConfigurationInput::RewardAddressChanged(new_reward_address) => { let new_reward_address = new_reward_address.trim(); diff --git a/src/frontend/running.rs b/src/frontend/running.rs index 0ca2786c..639ee024 100644 --- a/src/frontend/running.rs +++ b/src/frontend/running.rs @@ -2,9 +2,7 @@ use crate::backend::farmer::{PlottingKind, PlottingState}; use crate::backend::node::{SyncKind, SyncState}; use crate::backend::{FarmerNotification, NodeNotification}; use gtk::prelude::*; -use relm4::component::{AsyncComponent, AsyncComponentParts}; use relm4::prelude::*; -use relm4::AsyncComponentSender; use subspace_core_primitives::BlockNumber; use tracing::warn; @@ -36,8 +34,8 @@ pub struct RunningView { farmer_state: FarmerState, } -#[relm4::component(async, pub)] -impl AsyncComponent for RunningView { +#[relm4::component(pub)] +impl Component for RunningView { type Init = (); type Input = RunningInput; type Output = (); @@ -184,11 +182,11 @@ impl AsyncComponent for RunningView { } } - async fn init( + fn init( _init: Self::Init, - _root: Self::Root, - _sender: AsyncComponentSender, - ) -> AsyncComponentParts { + _root: &Self::Root, + _sender: ComponentSender, + ) -> ComponentParts { let model = Self { node_state: NodeState::default(), farmer_state: FarmerState::default(), @@ -196,21 +194,16 @@ impl AsyncComponent for RunningView { let widgets = view_output!(); - AsyncComponentParts { model, widgets } + ComponentParts { model, widgets } } - async fn update( - &mut self, - input: Self::Input, - _sender: AsyncComponentSender, - _root: &Self::Root, - ) { - self.process_input(input).await; + fn update(&mut self, input: Self::Input, _sender: ComponentSender, _root: &Self::Root) { + self.process_input(input); } } impl RunningView { - async fn process_input(&mut self, input: RunningInput) { + fn process_input(&mut self, input: RunningInput) { match input { RunningInput::Initialize { best_block_number, diff --git a/src/main.rs b/src/main.rs index 15894ecb..e5b01584 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,8 +60,8 @@ struct App { current_view: View, backend_action_sender: mpsc::Sender, loading_view: Controller, - configuration_view: AsyncController, - running_view: AsyncController, + configuration_view: Controller, + running_view: Controller, menu_popover: gtk::Popover, about_dialog: gtk::AboutDialog, }