Skip to content

Commit

Permalink
refactor: remove unnecessary current_screen arg from `App::init_det…
Browse files Browse the repository at this point in the history
…ails_actions`

The method `App::init_details_actions`, used to initialize an instance
of the screen "Patchset Details and Actions", has an argument
`current_screen` to resolve if the patchset to be opened is from the
latest or bookmarked patchsets. However, this can be resolved by just
checking the field `App::current_screen`, so remove this unnecessary
argument.

Signed-off-by: David Tadokoro <[email protected]>
  • Loading branch information
davidbtadokoro committed Nov 19, 2024
1 parent 68c0892 commit 428d5ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,11 @@ impl App {
/// Initializes field [App::details_actions], from currently selected
/// patchset in [App::bookmarked_patchsets] or [App::latest_patchsets],
/// depending on the value of [App::current_screen].
pub fn init_details_actions(
&mut self,
current_screen: CurrentScreen,
) -> color_eyre::Result<()> {
pub fn init_details_actions(&mut self) -> color_eyre::Result<()> {
let representative_patch: Patch;
let mut is_patchset_bookmarked = true;

match current_screen {
match &self.current_screen {
CurrentScreen::BookmarkedPatchsets => {
representative_patch = self.bookmarked_patchsets.get_selected_patchset();
}
Expand Down Expand Up @@ -190,7 +187,7 @@ impl App {
(PatchsetAction::Bookmark, is_patchset_bookmarked),
(PatchsetAction::ReplyWithReviewedBy, false),
]),
last_screen: current_screen,
last_screen: self.current_screen.clone(),
lore_api_client: self.lore_api_client.clone(),
});
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/handler/bookmarked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
terminal = loading_screen! {
terminal,
"Loading patchset" => {
app.init_details_actions(CurrentScreen::BookmarkedPatchsets)?;
app.init_details_actions()?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/handler/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where
terminal = loading_screen! {
terminal,
"Loading patchset" => {
app.init_details_actions(CurrentScreen::LatestPatchsets)?;
app.init_details_actions()?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
};
Expand Down

0 comments on commit 428d5ef

Please sign in to comment.