diff --git a/OSGKeyboard/Services/DictionaryLearner.swift b/OSGKeyboard/Services/DictionaryLearner.swift index 0815f03..e11f84f 100644 --- a/OSGKeyboard/Services/DictionaryLearner.swift +++ b/OSGKeyboard/Services/DictionaryLearner.swift @@ -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. diff --git a/OSGKeyboard/Views/PersonalDictionaryView.swift b/OSGKeyboard/Views/PersonalDictionaryView.swift index 922db10..50f5e30 100644 --- a/OSGKeyboard/Views/PersonalDictionaryView.swift +++ b/OSGKeyboard/Views/PersonalDictionaryView.swift @@ -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 diff --git a/OSGKeyboardShared/Services/AppGroupStore.swift b/OSGKeyboardShared/Services/AppGroupStore.swift index 0879835..b99b5f4 100644 --- a/OSGKeyboardShared/Services/AppGroupStore.swift +++ b/OSGKeyboardShared/Services/AppGroupStore.swift @@ -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 } }