forked from janek/mostr
1
0
Fork 0

fix(main): hide Quick Access in a custom search

Matching items are included anyway
This commit is contained in:
xeruf 2024-11-09 19:36:52 +01:00
parent ae525c870f
commit 8f0a169677
1 changed files with 22 additions and 20 deletions

View File

@ -1191,26 +1191,28 @@ impl Display for TasksRelay {
let tree = current.iter().flat_map(|task| self.traverse_up_from(Some(task.event.id))).unique(); let tree = current.iter().flat_map(|task| self.traverse_up_from(Some(task.event.id))).unique();
let ids: HashSet<&EventId> = tree.map(|t| t.get_id()).chain(position).collect(); let ids: HashSet<&EventId> = tree.map(|t| t.get_id()).chain(position).collect();
let mut bookmarks = if self.view.is_empty() {
// TODO add recent tasks (most time tracked + recently created) let mut bookmarks =
self.bookmarks.iter() // TODO add recent tasks (most time tracked + recently created)
.chain(self.tasks.values().sorted_unstable().take(3).map(|t| t.get_id())) self.bookmarks.iter()
.filter(|id| !ids.contains(id)) .chain(self.tasks.values().sorted_unstable().take(3).map(|t| t.get_id()))
.filter_map(|id| self.get_by_id(id)) .filter(|id| !ids.contains(id))
.filter(|t| self.filter(t)) .filter_map(|id| self.get_by_id(id))
.sorted_by_cached_key(|t| self.sorting_key(t)) .filter(|t| self.filter(t))
.dedup() .sorted_by_cached_key(|t| self.sorting_key(t))
.peekable(); .dedup()
if bookmarks.peek().is_some() { .peekable();
writeln!(lock, "{}", Colorize::bold("Quick Access"))?; if bookmarks.peek().is_some() {
for task in bookmarks { writeln!(lock, "{}", Colorize::bold("Quick Access"))?;
writeln!( for task in bookmarks {
lock, writeln!(
"{}", lock,
self.properties.iter() "{}",
.map(|p| self.get_property(task, p.as_str())) self.properties.iter()
.join(" \t") .map(|p| self.get_property(task, p.as_str()))
)?; .join(" \t")
)?;
}
} }
} }