fix: no-op unknown removal, earlier-duplicate editor check, list focus for delete/undo

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 15:53:15 +02:00
co-authored by Claude Sonnet 5.5
parent 9a5794c1e0
commit d34d3e92da
4 changed files with 44 additions and 3 deletions
+9 -1
View File
@@ -134,7 +134,14 @@ public final class DictionaryViewModel: ObservableObject {
/// Live feedback for the editor; `id` is the entry being edited (nil for a new one).
public func warnings(for kind: DictionaryEntry.Kind, editing id: UUID?) -> [EntryWarning] {
EntryWarnings.check(kind, among: store.entries.filter { $0.id != id }, knowledge: knowledge)
let entries = store.entries
let others: [DictionaryEntry]
if let id, let index = entries.firstIndex(where: { $0.id == id }) {
others = Array(entries[..<index])
} else {
others = entries
}
return EntryWarnings.check(kind, among: others, knowledge: knowledge)
}
@discardableResult
@@ -149,6 +156,7 @@ public final class DictionaryViewModel: ObservableObject {
}
public func remove(id: UUID) {
guard store.entries.contains(where: { $0.id == id }) else { return }
mutate { $0.remove(id: id) }
}