From 36d1c74625e64d6fa28134c52ed0bcbd3ab406d2 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 21 Jun 2023 14:42:16 +0200 Subject: [PATCH] Add button to view own profile --- src/components/comment_row.rs | 2 +- src/main.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/comment_row.rs b/src/components/comment_row.rs index c967e76..0571d3d 100644 --- a/src/components/comment_row.rs +++ b/src/components/comment_row.rs @@ -70,7 +70,7 @@ impl FactoryComponent for CommentRow { }, gtk::Box { - set_orientation: gtk::Orientation::Vertical, + set_orientation: gtk::Orientation::Horizontal, #[local_ref] voting_row -> gtk::Box {}, diff --git a/src/main.rs b/src/main.rs index 9e1efc6..4de5897 100644 --- a/src/main.rs +++ b/src/main.rs @@ -254,6 +254,7 @@ impl SimpleComponent for App { menu! { menu_model: { "Choose Instance" => ChangeInstanceAction, + "Profile" => ProfileAction, "Login" => LoginAction, "Logout" => LogoutAction } @@ -294,6 +295,11 @@ impl SimpleComponent for App { let instance_action: RelmAction = RelmAction::new_stateless(move |_| { instance_sender.input(AppMsg::ChooseInstance); }); + let profile_sender = sender.clone(); + let profile_action: RelmAction = RelmAction::new_stateless(move |_| { + let person = settings::get_current_account().name; + if !person.is_empty() { profile_sender.input(AppMsg::OpenPerson(person)); } + }); let login_sender = sender.clone(); let login_action: RelmAction = RelmAction::new_stateless(move |_| { login_sender.input(AppMsg::ShowLogin); @@ -304,6 +310,7 @@ impl SimpleComponent for App { let mut group = RelmActionGroup::::new(); group.add_action(instance_action); + group.add_action(profile_action); group.add_action(login_action); group.add_action(logout_action); group.register_for_widget(&widgets.main_window); @@ -416,6 +423,7 @@ impl SimpleComponent for App { let user = site.my_user.unwrap().local_user_view.person; account.name = user.name; account.id = user.id.0; + settings::update_current_account(account); } AppMsg::StartFetchPosts(None) } else { @@ -445,6 +453,7 @@ impl SimpleComponent for App { relm4::new_action_group!(WindowActionGroup, "win"); relm4::new_stateless_action!(ChangeInstanceAction, WindowActionGroup, "instance"); +relm4::new_stateless_action!(ProfileAction, WindowActionGroup, "profile"); relm4::new_stateless_action!(LoginAction, WindowActionGroup, "login"); relm4::new_stateless_action!(LogoutAction, WindowActionGroup, "logout");