Skip to content
Merged
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
57 changes: 41 additions & 16 deletions src/ui/network_chooser_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ impl NetworkChooserScreen {
if ui.button("Select File").clicked()
&& let Some(path) = rfd::FileDialog::new().pick_file()
{
let previous_custom_dash_qt_path = self.custom_dash_qt_path.clone();
let file_name = path.file_name().and_then(|f| f.to_str());
if let Some(file_name) = file_name {
self.custom_dash_qt_path = None;
self.custom_dash_qt_error_message = None;

// Handle macOS .app bundles
Expand All @@ -886,7 +886,14 @@ impl NetworkChooserScreen {
if is_valid {
self.custom_dash_qt_path = Some(resolved_path);
self.custom_dash_qt_error_message = None;
self.save().expect("Expected to save db settings");
if let Err(e) = self.save() {
tracing::warn!("Failed to save Dash-Qt path setting: {}", e);
self.custom_dash_qt_error_message = Some(
"Failed to save Dash-Qt path setting. Please try again."
.to_string(),
);
self.custom_dash_qt_path = previous_custom_dash_qt_path;
}
} else {
let required_file_name = if cfg!(target_os = "windows") {
"dash-qt.exe"
Expand All @@ -904,24 +911,33 @@ impl NetworkChooserScreen {
}

if self.custom_dash_qt_path.is_some() && ui.button("Clear").clicked() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

"Clear" button remains visible after a successful clear due to condition mismatch.

Line 913 guards the "Clear" button with self.custom_dash_qt_path.is_some(), but after a successful clear custom_dash_qt_path is set to Some(PathBuf::new()), which still satisfies is_some(). Meanwhile, the path display at lines 928–929 correctly gates on !file.as_os_str().is_empty() and shows nothing. The result is a "Clear" button with no path shown — pressing it again is a silent no-op that still triggers a save() call.

Align the button guard with the display guard:

🛠 Proposed fix
-                    if self.custom_dash_qt_path.is_some() && ui.button("Clear").clicked() {
+                    if self.custom_dash_qt_path.as_ref().is_some_and(|p| !p.as_os_str().is_empty()) && ui.button("Clear").clicked() {

Also applies to: 928-929

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ui/network_chooser_screen.rs` at line 913, The Clear button guard uses
self.custom_dash_qt_path.is_some() which stays true after clearing because you
set it to Some(PathBuf::new()); change the Clear button condition to match the
path display check by ensuring the concrete PathBuf is non-empty (e.g. compute
the PathBuf used for display from self.custom_dash_qt_path and guard on
!file.as_os_str().is_empty()). Update the same logic where the button is created
(referencing self.custom_dash_qt_path and the save() call) so the Clear button
is only shown when an actual path is present and save() is only invoked when
clearing a non-empty path.

let previous_custom_dash_qt_path = self.custom_dash_qt_path.clone();
self.custom_dash_qt_path = Some(PathBuf::new());
self.custom_dash_qt_error_message = None;
self.save().expect("Expected to save db settings");
if let Err(e) = self.save() {
tracing::warn!("Failed to save cleared Dash-Qt path setting: {}", e);
self.custom_dash_qt_error_message = Some(
"Failed to clear Dash-Qt path setting. Please try again."
.to_string(),
);
self.custom_dash_qt_path = previous_custom_dash_qt_path;
}
}
});

if let Some(ref file) = self.custom_dash_qt_path {
if !file.as_os_str().is_empty() {
ui.horizontal(|ui| {
ui.label("Path:");
ui.label(
egui::RichText::new(format_path_for_display(file))
.color(DashColors::SUCCESS)
.italics(),
);
});
}
} else if let Some(ref error) = self.custom_dash_qt_error_message {
if let Some(ref file) = self.custom_dash_qt_path
&& !file.as_os_str().is_empty()
{
ui.horizontal(|ui| {
ui.label("Path:");
ui.label(
egui::RichText::new(format_path_for_display(file))
.color(DashColors::SUCCESS)
.italics(),
);
});
}
if let Some(ref error) = self.custom_dash_qt_error_message {
let error_color = Color32::from_rgb(255, 100, 100);
let error = error.clone();
Frame::new()
Expand Down Expand Up @@ -952,11 +968,20 @@ impl NetworkChooserScreen {
ui.add_space(8.0);

ui.horizontal(|ui| {
let previous_overwrite_dash_conf = self.overwrite_dash_conf;
if StyledCheckbox::new(&mut self.overwrite_dash_conf, "Overwrite dash.conf")
.show(ui)
.clicked()
{
self.save().expect("Expected to save db settings");
self.custom_dash_qt_error_message = None;
if let Err(e) = self.save() {
tracing::warn!("Failed to save overwrite_dash_conf setting: {}", e);
self.custom_dash_qt_error_message = Some(
"Failed to save overwrite dash.conf setting. Please try again."
.to_string(),
);
self.overwrite_dash_conf = previous_overwrite_dash_conf;
}
}
ui.label(
egui::RichText::new("Auto-configure required settings")
Expand Down
Loading