From 7fa0b20cb779fd84d66442763ffec87ba54f938c Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 4 Aug 2026 21:34:48 +0800 Subject: duckduckgo: stricter ok state --- qml_plugin/src/launcher/duckduckgo.rs | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'qml_plugin/src') diff --git a/qml_plugin/src/launcher/duckduckgo.rs b/qml_plugin/src/launcher/duckduckgo.rs index a2785f2..691c9da 100644 --- a/qml_plugin/src/launcher/duckduckgo.rs +++ b/qml_plugin/src/launcher/duckduckgo.rs @@ -65,24 +65,36 @@ impl qobject::DuckDuckGo { .executor .spawn( async move { - let input = input.to_string(); - let result: Result = duckduckgo::query(&input) + let qinput = input.to_string(); + let result: Result = duckduckgo::query(&qinput) .await .map(|r| r.into()); // consider just unwrapping since this is in a separate thread and is already // end of life anw _ = qt_thread .queue( - |mut qo| match result { + move |mut qo| match result { Ok(r) => { - qo.as_mut() - .set_ok(true); - qo.as_mut() - .set_title(r.title); - qo.as_mut() - .set_description_html(r.description_html); - qo.as_mut() - .set_image(r.image); + if (r.title == input + || r.title + .is_empty()) + && r.description_html + .is_empty() + && r.image + .is_empty() + { + qo.as_mut() + .set_ok(false); + } else { + qo.as_mut() + .set_ok(true); + qo.as_mut() + .set_title(r.title); + qo.as_mut() + .set_description_html(r.description_html); + qo.as_mut() + .set_image(r.image); + } } Err(_) => qo.set_ok(false), }, -- cgit v1.2.3