Order the project picker by most recently selected

This commit is contained in:
Ian Gulliver
2026-10-22 13:16:19 -07:00
parent e61e491d47
commit d5ffd5b128
2 changed files with 14 additions and 10 deletions
+6 -6
View File
@@ -234,19 +234,19 @@ final class SwitcherModel {
}
return a.i < b.i
}
let focused = store.focusedProject()?.id
let used = store.projects.enumerated().map { i, p in
(i: i, project: p, at: p.id == focused ? Double.infinity : ((store.tasks[p.id] ?? []).map { visits[$0.id] ?? 0 } + [visits[p.id] ?? 0]).max()!)
}
let recent = used.sorted { $0.at != $1.at ? $0.at > $1.at : $0.i < $1.i }.map(\.project)
let images = store.images.images(imageKey).count
var rows: [SwitcherRow] = []
if images == 0 {
rows = matches.map { SwitcherRow(id: "task:\($0.task.id)", kind: .task($0.project, $0.task, $0.count)) }
for p in (targets ?? store.projects) where includes("\(p.name) project".lowercased(), q) {
for p in (targets ?? recent) where includes("\(p.name) project".lowercased(), q) {
rows.append(SwitcherRow(id: "project:\(p.id)", kind: .project(p)))
}
}
let focused = store.focusedProject()?.id
let used = store.projects.enumerated().map { i, p in
(i: i, project: p, at: p.id == focused ? Double.infinity : (store.tasks[p.id] ?? []).map { visits[$0.id] ?? 0 }.max() ?? 0)
}
let recent = used.sorted { $0.at != $1.at ? $0.at > $1.at : $0.i < $1.i }.map(\.project)
let workflow = images == 0 ? workflowMatch(title) : nil
for project in targets ?? recent {
if title.isEmpty && images == 0 {