Merge pull request #14 from hkgood/cursor/fix-personal-dictionary-preview-6baf

fix: PersonalDictionaryView preview and dictionary persistence
This commit is contained in:
cursor[bot]
2026-07-03 08:19:51 +00:00
committed by GitHub
3 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ final class DictionaryLearner {
if didChange {
dictionary.version += 1
store.personalDictionary = dictionary
store.setPersonalDictionary(dictionary)
}
// Suppress the "did not change" path; we still return the
// bumped-counts view so the caller can refresh a UI label.
@@ -224,11 +224,14 @@ struct PersonalDictionaryView: View {
private func persist() {
dictionary.version += 1
store.personalDictionary = dictionary
store.setPersonalDictionary(dictionary)
}
}
#if DEBUG
#Preview {
PersonalDictionaryView()
.environment(\.themePalette, ThemePalette())
ThemedRoot {
PersonalDictionaryView()
}
}
#endif
+12 -8
View File
@@ -341,14 +341,18 @@ public struct AppGroupStore: @unchecked Sendable {
}
}
set {
do {
let data = try JSONEncoder().encode(newValue)
defaults.set(data, forKey: Key.personalDictionary)
} catch {
#if DEBUG
print("⚠️ [AppGroupStore] personalDictionary encode failed: \(error)")
#endif
}
setPersonalDictionary(newValue)
}
}
public func setPersonalDictionary(_ dictionary: PersonalDictionary) {
do {
let data = try JSONEncoder().encode(dictionary)
defaults.set(data, forKey: Key.personalDictionary)
} catch {
#if DEBUG
print("⚠️ [AppGroupStore] personalDictionary encode failed: \(error)")
#endif
}
}