feat: rank built-in commands alongside applications

This commit is contained in:
Valdemar Lorenzen
2026-10-15 11:23:50 +02:00
parent 31c651ecb1
commit e0f17c6339
7 changed files with 131 additions and 43 deletions
+4 -2
View File
@@ -18,7 +18,8 @@ public final class LaunchHistory {
self.defaults = defaults
self.now = now
for (identifier, value) in defaults.dictionary(forKey: Self.storageKey) ?? [:] {
guard let url = URL(string: identifier), url.isFileURL,
guard let url = URL(string: identifier),
url.isFileURL || Application.commands.contains(where: { $0.id == url }),
let record = value as? [String: Any],
let count = record["count"] as? Int, count > 0,
let lastLaunch = record["lastLaunch"] as? Date,
@@ -26,7 +27,8 @@ public final class LaunchHistory {
usage[url] = Usage(count: count, lastLaunch: lastLaunch)
}
for identifier in defaults.stringArray(forKey: Self.favoritesStorageKey) ?? [] {
guard let url = URL(string: identifier), url.isFileURL else { continue }
guard let url = URL(string: identifier),
url.isFileURL || Application.commands.contains(where: { $0.id == url }) else { continue }
favorites.insert(url)
}
}