Skip to content

Commit

Permalink
feat(profiles): blank profiles builder event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
krypt0nn committed Nov 30, 2024
1 parent a415e32 commit c15ee29
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
13 changes: 9 additions & 4 deletions src/ui/windows/main_window/profile_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl AsyncFactoryComponent for ProfileFactoryComponent {
#[derive(Debug, Clone)]
pub enum ProfilePageMsg {
UpdateProfiles,
CreateProfile,
OpenNewProfileDialog,
CreateProfile(Profile),
EditProfile(DynamicIndex),
DeleteProfile(DynamicIndex)
}
Expand Down Expand Up @@ -83,7 +84,7 @@ impl SimpleAsyncComponent for ProfilePage {

set_tooltip_text: Some("Create new profile"),

connect_clicked => ProfilePageMsg::CreateProfile
connect_clicked => ProfilePageMsg::OpenNewProfileDialog
},

model.profiles.widget(),
Expand All @@ -95,7 +96,7 @@ impl SimpleAsyncComponent for ProfilePage {
let model = Self {
builder_window: ProfileBuilderWindow::builder()
.launch(())
.detach(),
.forward(sender.input_sender(), ProfilePageMsg::CreateProfile),

manager_window: ProfileManagerWindow::builder()
.launch(())
Expand Down Expand Up @@ -135,10 +136,14 @@ impl SimpleAsyncComponent for ProfilePage {
}
}

ProfilePageMsg::CreateProfile => {
ProfilePageMsg::OpenNewProfileDialog => {
self.builder_window.emit(ProfileBuilderWindowInput::OpenWindow);
}

ProfilePageMsg::CreateProfile(profile) => {
dbg!(profile);
}

ProfilePageMsg::EditProfile(index) => {
if let Some(profile) = self.profiles.guard().get(index.current_index()) {
self.manager_window.emit(ProfileManagerWindowMsg::OpenWindow(profile.0.clone()));
Expand Down
3 changes: 1 addition & 2 deletions src/ui/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ pub use profile_manager::{

pub use profile_manager::builder::{
ProfileBuilderWindow,
ProfileBuilderWindowInput,
ProfileBuilderWindowOutput
ProfileBuilderWindowInput
};

pub use download_manager::{
Expand Down
9 changes: 2 additions & 7 deletions src/ui/windows/profile_manager/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ pub enum ProfileBuilderWindowInput {
EmitClick
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProfileBuilderWindowOutput {
NewProfile(Profile)
}

#[relm4::component(pub, async)]
impl SimpleAsyncComponent for ProfileBuilderWindow {
type Init = ();
type Input = ProfileBuilderWindowInput;
type Output = ProfileBuilderWindowOutput;
type Output = Profile;

view! {
#[root]
Expand Down Expand Up @@ -199,7 +194,7 @@ impl SimpleAsyncComponent for ProfileBuilderWindow {
}
};

let _ = sender.output(ProfileBuilderWindowOutput::NewProfile(profile));
let _ = sender.output(profile);

if let Some(window) = &self.window {
window.close();
Expand Down

0 comments on commit c15ee29

Please sign in to comment.