fix(discovery): skip redundant modpack confirmation
This commit is contained in:
1 parent
d79843c54b
commit
1fa9aee3f0
5 files changed
+74
-19
No files matched your search
@@ -297,9 +297,16 @@ fn render_confirm_step(state: &ImportWizardState, area: Rect, buf: &mut ratatui:
|
||||
.render(area, buf);
|
||||
}
|
||||
|
||||
fn wizard_title(_state: &ImportWizardState) -> Line<'static> {
|
||||
fn wizard_title(state: &ImportWizardState) -> Line<'static> {
|
||||
use crate::tui::widgets::styled_title;
|
||||
styled_title("Import Modpack", false)
|
||||
styled_title(
|
||||
if state.step == ImportStep::Confirm {
|
||||
"Install Modpack"
|
||||
} else {
|
||||
"Import Modpack"
|
||||
},
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
fn step_keybinds(state: &ImportWizardState) -> Line<'static> {
|
||||
@@ -311,7 +318,7 @@ fn step_keybinds(state: &ImportWizardState) -> Line<'static> {
|
||||
ImportStep::Version => {
|
||||
keybind_line(&[("/", " search"), ("h", " back"), ("Enter", " select")])
|
||||
}
|
||||
ImportStep::Confirm => keybind_line(&[("h", " back"), ("Enter", " import")]),
|
||||
ImportStep::Confirm => keybind_line(&[("h", " back"), ("Enter", " install")]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,18 +162,10 @@ fn handle_discovery_key(key_event: &KeyEvent, instances_state: &mut instances::S
|
||||
}
|
||||
}
|
||||
KeyCode::Enter if popup_open => {
|
||||
let confirming = discovery
|
||||
.version_popup
|
||||
.as_ref()
|
||||
.is_some_and(|popup| popup.confirming);
|
||||
if confirming {
|
||||
let request = discovery.begin_install();
|
||||
drop(discovery);
|
||||
if let Some(request) = request {
|
||||
start_discovered_download(request);
|
||||
}
|
||||
} else {
|
||||
discovery.begin_confirmation();
|
||||
let request = take_discovered_version(&mut discovery);
|
||||
drop(discovery);
|
||||
if let Some(request) = request {
|
||||
start_discovered_download(request);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@@ -191,6 +183,14 @@ fn handle_discovery_key(key_event: &KeyEvent, instances_state: &mut instances::S
|
||||
}
|
||||
}
|
||||
|
||||
fn take_discovered_version(
|
||||
discovery: &mut crate::tui::widgets::content::DiscoveryState,
|
||||
) -> Option<crate::tui::widgets::content::discovery::InstallRequest> {
|
||||
discovery
|
||||
.begin_confirmation()
|
||||
.then(|| discovery.begin_install())?
|
||||
}
|
||||
|
||||
pub fn take_result() -> Option<ImportResult> {
|
||||
match IMPORT_RESULT.lock() {
|
||||
Ok(mut r) => r.take(),
|
||||
|
||||
Reference in new issue
Block a user