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:
@@ -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) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user