remove incorrect async features implementation

This commit is contained in:
yggverse 2025-07-23 02:13:48 +03:00
parent f831212d40
commit e2b0cd6b0d
2 changed files with 25 additions and 39 deletions

View File

@ -41,17 +41,11 @@ impl Bookmark {
let profile = self.profile.clone(); let profile = self.profile.clone();
let query = self.request.text(); let query = self.request.text();
let title = title.map(|t| t.to_string()); let title = title.map(|t| t.to_string());
gtk::glib::spawn_future_local(async move { button.set_sensitive(false); // lock
button.set_sensitive(false); // lock let has_bookmark = profile.bookmark.toggle(&query, title.as_deref()).unwrap();
let has_bookmark = gtk::gio::spawn_blocking(move || { button.set_icon_name(icon_name(has_bookmark));
profile.bookmark.toggle(&query, title.as_deref()).unwrap() button.set_tooltip_text(Some(tooltip_text(has_bookmark)));
}) button.set_sensitive(true);
.await
.unwrap();
button.set_icon_name(icon_name(has_bookmark));
button.set_tooltip_text(Some(tooltip_text(has_bookmark)));
button.set_sensitive(true);
}); // may take a while
} }
} }
@ -76,10 +70,7 @@ fn update(profile: &Arc<Profile>, button: &Button, request: gtk::glib::GString)
let button = button.clone(); let button = button.clone();
gtk::glib::spawn_future_local(async move { gtk::glib::spawn_future_local(async move {
button.set_sensitive(false); // lock button.set_sensitive(false); // lock
let has_bookmark = let has_bookmark = profile.bookmark.is_match_request(&request);
gtk::gio::spawn_blocking(move || profile.bookmark.is_match_request(&request))
.await
.unwrap();
button.set_icon_name(icon_name(has_bookmark)); button.set_icon_name(icon_name(has_bookmark));
button.set_tooltip_text(Some(tooltip_text(has_bookmark))); button.set_tooltip_text(Some(tooltip_text(has_bookmark)));
button.set_sensitive(true); button.set_sensitive(true);

View File

@ -170,31 +170,26 @@ impl Suggestion {
let list_store = self.list_store.clone(); let list_store = self.list_store.clone();
let profile = self.profile.clone(); let profile = self.profile.clone();
gtk::glib::spawn_future_local(async move { gtk::glib::spawn_future_local(async move {
let list_items: Vec<(GString, GString, bool, GString)> = let list_items: Vec<(GString, GString, bool, GString)> = profile
gtk::gio::spawn_blocking(move || { .history
profile .contains_request(&query, limit)
.history .into_iter()
.contains_request(&query, limit) .sorted_by(|a, b| Ord::cmp(&b.opened.count, &a.opened.count))
.into_iter() .map(|item| {
.sorted_by(|a, b| Ord::cmp(&b.opened.count, &a.opened.count)) let subtitle = highlight(&item.request, &query);
.map(|item| { let title = match item.title {
let subtitle = highlight(&item.request, &query); Some(title) => highlight(&title, &query),
let title = match item.title { None => subtitle.clone(),
Some(title) => highlight(&title, &query), };
None => subtitle.clone(), (
}; title,
( subtitle,
title, profile.bookmark.is_match_request(&item.request),
subtitle, item.request,
profile.bookmark.is_match_request(&item.request), )
item.request,
)
})
.sorted_by(|a, b| Ord::cmp(&b.2, &a.2)) // bookmark first
.collect()
}) })
.await .sorted_by(|a, b| Ord::cmp(&b.2, &a.2)) // bookmark first
.unwrap(); .collect();
if list_items.is_empty() { if list_items.is_empty() {
popover.popdown(); popover.popdown();
} else { } else {