Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
if app.mailing_list_selection.mailing_lists.is_empty() {
terminal = loading_screen! {
terminal, "Fetching mailing lists" => {
app.mailing_list_selection.refresh_available_mailing_lists()?;
app.mailing_list_selection.refresh_available_mailing_lists()
}
};
}
Expand All @@ -84,7 +84,7 @@ where
terminal = loading_screen! {
terminal,
format!("Fetching patchsets from {}", target_list) => {
patchsets_state.fetch_current_page()?;
patchsets_state.fetch_current_page()
}
};

Expand Down
7 changes: 5 additions & 2 deletions src/handler/bookmarked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ where
terminal = loading_screen! {
terminal,
"Loading patchset" => {
app.init_details_actions()?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
let result = app.init_details_actions();
if result.is_ok() {
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
result
}
};
}
Expand Down
9 changes: 6 additions & 3 deletions src/handler/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
terminal,
format!("Fetching patchsets from {}", list_name) => {
latest_patchsets.increment_page();
latest_patchsets.fetch_current_page()?;
latest_patchsets.fetch_current_page()
}
};
}
Expand All @@ -53,8 +53,11 @@ where
terminal = loading_screen! {
terminal,
"Loading patchset" => {
app.init_details_actions()?;
app.set_current_screen(CurrentScreen::PatchsetDetails);
let result = app.init_details_actions();
if result.is_ok() {
app.set_current_screen(CurrentScreen::PatchsetDetails);
}
result
}
};
}
Expand Down
13 changes: 9 additions & 4 deletions src/handler/mail_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ where
terminal = loading_screen! {
terminal,
format!("Fetching patchsets from {}", list_name) => {
app.latest_patchsets.as_mut().unwrap().fetch_current_page()?;
app.mailing_list_selection.clear_target_list();
app.set_current_screen(CurrentScreen::LatestPatchsets);
let result =
app.latest_patchsets.as_mut().unwrap()
.fetch_current_page();
if result.is_ok() {
app.mailing_list_selection.clear_target_list();
app.set_current_screen(CurrentScreen::LatestPatchsets);
}
result
}
};
}
Expand All @@ -49,7 +54,7 @@ where
terminal,
"Refreshing lists" => {
app.mailing_list_selection
.refresh_available_mailing_lists()?;
.refresh_available_mailing_lists()
}
};
}
Expand Down
15 changes: 12 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ pub fn binary_exists(binary: &str) -> bool {
///
/// When the execution finishes, the macro will return the terminal.
///
/// Important to notice that the code block will run in the same scope as the rest of the macro
/// Important to notice that the code block will run in the same scope as the rest of the macro.
/// Be aware that in Rust, when using `?` or `return` inside a closure, they apply to the outer function,
/// not the closure itself. This can lead to unexpected behavior if you expect the closure to handle
/// errors or return values independently of the enclosing function.
///
/// # Example
/// ```rust norun
Expand All @@ -109,11 +112,17 @@ macro_rules! loading_screen {
terminal
});

$inst;
// we have to sleep so the loading thread completes at least one render
std::thread::sleep(std::time::Duration::from_millis(200));
let inst_result = $inst;

loading.store(false, std::sync::atomic::Ordering::Relaxed);

handle.join().unwrap()
let terminal = handle.join().unwrap();

inst_result?;

terminal
}
};
}
Expand Down