mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
show bookmarked suggestions first
This commit is contained in:
parent
6f82924b4f
commit
d6018dc66a
1 changed files with 28 additions and 24 deletions
|
|
@ -170,30 +170,34 @@ 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 = gtk::gio::spawn_blocking(move || {
|
let list_items: Vec<(GString, GString, bool, GString)> =
|
||||||
let result = profile
|
gtk::gio::spawn_blocking(move || {
|
||||||
.history
|
let result = 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()
|
||||||
let mut list_items = Vec::with_capacity(result.len());
|
.sorted_by(|a, b| Ord::cmp(&b.opened.count, &a.opened.count));
|
||||||
for item in result {
|
let mut list_items = Vec::with_capacity(result.len());
|
||||||
let subtitle = highlight(&item.request, &query);
|
for item in result {
|
||||||
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(),
|
||||||
list_items.push((
|
};
|
||||||
title,
|
list_items.push((
|
||||||
subtitle,
|
title,
|
||||||
profile.bookmark.is_match_request(&item.request),
|
subtitle,
|
||||||
item.request,
|
profile.bookmark.is_match_request(&item.request),
|
||||||
))
|
item.request,
|
||||||
}
|
))
|
||||||
list_items
|
}
|
||||||
})
|
list_items
|
||||||
.await
|
.into_iter()
|
||||||
.unwrap();
|
.sorted_by(|a, b| Ord::cmp(&b.2, &a.2)) // bookmark first
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
if list_items.is_empty() {
|
if list_items.is_empty() {
|
||||||
popover.popdown();
|
popover.popdown();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue