summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-08-04 21:34:48 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-08-04 23:29:44 +0800
commit7fa0b20cb779fd84d66442763ffec87ba54f938c (patch)
treedcbf1d6bee4e74965002890c73a79f4d90255f31
parent605794a9efa52df7a20a377d3448dc078bda5529 (diff)
duckduckgo: stricter ok state
-rw-r--r--qml_plugin/src/launcher/duckduckgo.rs34
1 files changed, 23 insertions, 11 deletions
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<QmlDuckDuckGo, _> = duckduckgo::query(&input)
+ let qinput = input.to_string();
+ let result: Result<QmlDuckDuckGo, _> = 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),
},