Skip to content

Commit aa47efd

Browse files
th-duvaneldavidbtadokoro
authored andcommitted
src: main: Don't return "Bookmarked Patchsets" when there are no entries
When consulting bookmarked patchsets, if the patchset is the only bookmarked one and the user unbookmarks it, the application returns to an empty "Bookmarked Patchsets" screen. Even worse, if the user hits ENTER, as if it were to select an highlighted entry, the application panics. To fix this strange behavior and the mentioned bug, return "Mailing Lists Selection" screen when removing the last bookmarked patchset. Closes: #12 [Maintainer edits] - Change commit message to convey the context of the strange behavior and bug, and how it fixes both with a single solution. Signed-off-by: Thiago Duvanel <[email protected]> Reviewed-by: David Tadokoro <[email protected]> Signed-off-by: David Tadokoro <[email protected]>
1 parent 0ccf41a commit aa47efd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> color_eyre:
3333
loop {
3434
terminal.draw(|f| draw_ui(f, &app))?;
3535

36-
if app.current_screen == CurrentScreen::MailingListSelection
37-
&& app.mailing_list_selection_state.mailing_lists.len() == 0
38-
{
39-
app.mailing_list_selection_state.refresh_available_mailing_lists()?;
36+
match app.current_screen {
37+
CurrentScreen::MailingListSelection => {
38+
if app.mailing_list_selection_state.mailing_lists.is_empty() {
39+
app.mailing_list_selection_state.refresh_available_mailing_lists()?;
40+
}
41+
},
42+
CurrentScreen::BookmarkedPatchsets => {
43+
if app.bookmarked_patchsets_state.bookmarked_patchsets.is_empty() {
44+
app.set_current_screen(CurrentScreen::MailingListSelection);
45+
}
46+
},
47+
_ => {},
4048
}
4149

4250
if event::poll(std::time::Duration::from_millis(16))? {

0 commit comments

Comments
 (0)