-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
キャラクター並び替えダイアログ: speakerUuidが異なる場合にstyleIdの重複を許容する #754
Merged
Hiroshiba
merged 2 commits into
VOICEVOX:main
from
aoirint:patch-multiple-engine-character-order-dialog
Jun 21, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上で、undefinedになる可能性が無いのであれば
| undefined
は逆に混乱しちゃうかなと感じました。(もしくはここはundefinedableだったりする・・・?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらについては、selectedStyleIndexはundefinedになる可能性があります。
このPRの変更前の実装では、selectedStyleIndexesにはprops.characterInfosに基づく初期値が設定されていましたが、このPRでは、初期値を空objectに変更しています。
その結果、selectedStyleIndexを更新する処理であるrollStyleIndexが一度も実行されていないキャラクターは、selectedStyleIndexがundefinedであるようになっています。
styleIdの重複許容に対して余計な差分が入っていてわかりにくく申し訳ないですが、これは複数エンジン対応時を想定した挙動の修正です。
従来の実装では、
props.characerInfos
が後で(初回setup呼び出し後に)書き換えられたとき、selectedStyleIndexes
の値が再計算されない(refの初期値または変更された値が維持される)ため、書き換え後に新しく含まれるようになったキャラクターについてのみ、selectedStyleIndex
がundefinedになる形でした。setup実行時のprops.characterInfosの値によらず、挙動をそろえるためにselectedStyleIndexの初期値をundefinedに統一しています。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどです!!
より良く意図を反映できるコードを思いつきました!!
たぶんなのですが、objectにキーがない場合にundefinedになる感じですよね。
であれば、キーの有無で処理を分岐させるのが一番意図が伝わりやすいかも…?
(でもまあここのコードはここでしか使われないので、正直どちらでもそこまで問題ないかなとも思いました…!)