feat(discovery): show status activity while loading results
This commit is contained in:
1 parent
88dfef51ad
commit
9932de1c73
8 files changed
+108
-5
No files matched your search
@@ -2041,6 +2041,40 @@ impl DiscoveryState {
|
||||
.is_some_and(|changed| changed.elapsed() >= SEARCH_DEBOUNCE)
|
||||
}
|
||||
|
||||
pub(crate) fn activity_label(&self) -> Option<&'static str> {
|
||||
if self.local_mode {
|
||||
return None;
|
||||
}
|
||||
if self.search_changed_at.is_some() || self.page_loading {
|
||||
return Some(if self.next_offset == 0 {
|
||||
"Searching Discovery..."
|
||||
} else {
|
||||
"Loading more results..."
|
||||
});
|
||||
}
|
||||
if self.retry_page_at.is_some() {
|
||||
return Some("Retrying Discovery...");
|
||||
}
|
||||
if self
|
||||
.version_popup
|
||||
.as_ref()
|
||||
.is_some_and(|popup| popup.loading)
|
||||
{
|
||||
return Some("Loading versions...");
|
||||
}
|
||||
if self.filter_version_picker_open
|
||||
&& self.filter_game_versions.lock().is_ok_and(|versions| {
|
||||
matches!(*versions, crate::tui::widgets::popups::LoadState::Loading)
|
||||
})
|
||||
{
|
||||
return Some("Loading game versions...");
|
||||
}
|
||||
if self.list.has_pending_icons() {
|
||||
return Some("Loading Discovery icons...");
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn apply_selected_sort(&mut self) {
|
||||
if self.local_mode {
|
||||
let selected = self.sort_panel_selected + 5;
|
||||
|
||||
@@ -8,8 +8,8 @@ mod state;
|
||||
pub use render::render;
|
||||
pub use render::{popup_rect, render_with_picker};
|
||||
pub use state::{
|
||||
ImportResult, ImportStep, ImportWizardState, drain, handle_discovery_click, handle_key,
|
||||
has_version_popup, open, take_result,
|
||||
ImportResult, ImportStep, ImportWizardState, discovery_activity, drain, handle_discovery_click,
|
||||
handle_key, has_version_popup, open, take_result,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -126,6 +126,18 @@ pub fn has_version_popup() -> bool {
|
||||
.is_ok_and(|state| state.version_popup.is_some())
|
||||
}
|
||||
|
||||
pub fn discovery_activity() -> Option<&'static str> {
|
||||
let wizard = IMPORT_STATE.lock().ok()?;
|
||||
let step = wizard.step.clone();
|
||||
let loading_versions = matches!(wizard.versions, LoadState::Loading);
|
||||
drop(wizard);
|
||||
match step {
|
||||
ImportStep::Discover => DISCOVERY_STATE.lock().ok()?.activity_label(),
|
||||
ImportStep::Version if loading_versions => Some("Loading modpack versions..."),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_discovery_click(x: u16, y: u16) -> bool {
|
||||
if !IMPORT_STATE
|
||||
.lock()
|
||||
|
||||
@@ -24,6 +24,7 @@ pub fn render(
|
||||
area: Rect,
|
||||
focused: FocusedArea,
|
||||
throbber_state: &mut ThrobberState,
|
||||
discovery_activity: Option<&str>,
|
||||
) {
|
||||
let theme = THEME.as_ref();
|
||||
let border_color = if focused == FocusedArea::Overview {
|
||||
@@ -50,7 +51,7 @@ pub fn render(
|
||||
}
|
||||
};
|
||||
|
||||
if state.current_action.is_none() {
|
||||
if state.current_action.is_none() && discovery_activity.is_none() {
|
||||
frame.render_widget(
|
||||
Paragraph::new(Span::styled("Ready", Style::default().fg(theme.text_dim())))
|
||||
.block(block),
|
||||
@@ -62,7 +63,11 @@ pub fn render(
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
|
||||
let action_text = state.current_action.as_deref().unwrap_or("");
|
||||
let action_text = state
|
||||
.current_action
|
||||
.as_deref()
|
||||
.or(discovery_activity)
|
||||
.unwrap_or("");
|
||||
let sub_text = state.sub_action.as_deref().unwrap_or("");
|
||||
|
||||
match state.progress {
|
||||
|
||||
Reference in new issue
Block a user