Skip to content

Commit

Permalink
feat: standardize loading screen for opening patchset
Browse files Browse the repository at this point in the history
Both when consulting the flow of patchsets from a target list or when
navigating through the bookmarked patches, we can open a patchset which
gets us to the screen "Patchset Details and Actions". In the former,
there is a notification of "Downloading patchset", while in the latter
it doesn't.

In this sense, standardize the use of a loading screen with the
notification "Loading patchset" for both cases.

Signed-off-by: David Tadokoro <davidbtadokoro@usp.br>
  • Loading branch information
davidbtadokoro committed Oct 31, 2024
1 parent 398f7c8 commit 3bd0294
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
return handle_mailing_list_selection(app, key, terminal);
}
CurrentScreen::BookmarkedPatchsets => {
handle_bookmarked_patchsets(app, key)?;
return handle_bookmarked_patchsets(app, key, terminal);
}
CurrentScreen::PatchsetDetails => {
handle_patchset_details(app, key, &mut terminal)?;
Expand Down
33 changes: 27 additions & 6 deletions src/handler/bookmarked.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
use crate::app::{screens::CurrentScreen, App};
use ratatui::crossterm::event::{KeyCode, KeyEvent};
use std::ops::ControlFlow;

pub fn handle_bookmarked_patchsets(app: &mut App, key: KeyEvent) -> color_eyre::Result<()> {
use crate::{
app::{screens::CurrentScreen, App},
loading_screen,
};
use ratatui::{
crossterm::event::{KeyCode, KeyEvent},
prelude::Backend,
Terminal,
};

pub fn handle_bookmarked_patchsets<B>(
app: &mut App,
key: KeyEvent,
mut terminal: Terminal<B>,
) -> color_eyre::Result<ControlFlow<(), Terminal<B>>>
where
B: Backend + Send + 'static,
{
match key.code {
KeyCode::Esc => {
app.bookmarked_patchsets_state.patchset_index = 0;
Expand All @@ -14,10 +30,15 @@ pub fn handle_bookmarked_patchsets(app: &mut App, key: KeyEvent) -> color_eyre::
app.bookmarked_patchsets_state.select_above_patchset();
}
KeyCode::Enter => {
app.init_patchset_details_and_actions_state(CurrentScreen::BookmarkedPatchsets)?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
terminal = loading_screen! {
terminal,
"Loading patchset" => {
app.init_patchset_details_and_actions_state(CurrentScreen::BookmarkedPatchsets)?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
};
}
_ => {}
}
Ok(())
Ok(ControlFlow::Continue(terminal))
}
2 changes: 1 addition & 1 deletion src/handler/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
KeyCode::Enter => {
terminal = loading_screen! {
terminal,
"Downloading patchset" => {
"Loading patchset" => {
app.init_patchset_details_and_actions_state(CurrentScreen::LatestPatchsets)?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
Expand Down

0 comments on commit 3bd0294

Please sign in to comment.