PR #320修正: ユーザー辞書のcompiled dictionary exportを保存時実行に整理#329
Open
artin-kagun wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
PR#320のご指摘に合わせて修正を行いました。
ユーザー辞書を保存・更新したタイミングで、変換器が利用できる compiled dictionary として export するようにします。
大きめのユーザー辞書を利用する場合でも、変換時に UserDefaults の辞書データを毎回扱うのではなく、あらかじめ export 済みの compiled dictionary を converter 側で参照できるようにする目的です。
変更内容
AppDelegateが保持している共有KanaKanjiConverterに対してupdateUserDictionaryURL(..., forceReload: true)を呼び、実行中のIMEへ再読み込みを通知metadata.json/fallback.jsonが生成されないことをテストで確認charID.chidを注入可能に変更レビューコメントへの対応
fallback JSONについて
この設計は削除しました。
compiled dictionary に含められない読みは
fallback.jsonに保存せず、export対象から除外するようにしています。また、変換時に fallback JSON を読み込んで dynamic dictionary として渡す処理も削除しました。
これにより、ユーザー環境に fallback 用の独自JSONファイルを保存し続けることを避けています。
読みのvalidationについて
このPRでは fallback JSON を使わない方針に変更しました。
一方で、既存の手動ユーザー辞書UIには読みとして登録可能な文字種を制限するvalidationがないため、このPRではUI仕様変更までは行っていません。
compiled dictionaryへexportできない読みは、fallback JSON に保存せず、export対象から除外する扱いにしています。
入力時・import時のvalidationについては、import機能側のPRで同じ判定を利用して扱うのが自然だと考えています。
metadata.jsonについて
この仕組みは削除しました。
metadata.jsonを保存せず、変換時にも modificationDate を見ないようにしています。converter経由のreloadについて
この方針に合わせ、設定変更時に compiled dictionary を export した後、
AppDelegateが保持している共有KanaKanjiConverterに対してupdateUserDictionaryURL(..., forceReload: true)を呼ぶようにしました。これにより、metadataファイルの更新検知ではなく、設定変更後に converter へ明示的にreloadを通知する形にしています。
ユーザー環境に保存するファイルについて
この指摘を踏まえ、
metadata.jsonとfallback.jsonは生成しないようにしました。ユーザー環境に保存されるのは、converter が利用する compiled dictionary のファイル群のみです。
動作確認
swift test --disable-sandbox --package-path Core --build-path /private/tmp/azookey-pr320-review-fix-buildgit diff --checkmetadata.json/fallback.jsonが生成されないことを確認