Refactor ensureSelectionExists for more readability

ab966db1e5ae9a7a6248314fd55529789f342b0e

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +3 -1Ignore whitespace
public/scripts/extensions/stable-diffusion/index.js+3 -1
@@ -2243,7 +2243,9 @@ function ensureSelectionExists(setting, selector) {
22432243 if (!selectElement) {
22442244 return;
22452245 }
2246- if (selectElement.selectedOptions.length && !Array.from(selectElement.options).some(option => option.value === extension_settings.sd[setting])) {
2246+ const options = Array.from(selectElement.options);
2247+ const value = extension_settings.sd[setting];
2248+ if (selectElement.selectedOptions.length && !options.some(option => option.value === value)) {
22472249 extension_settings.sd[setting] = selectElement.selectedOptions[0].value;
22482250 }
22492251}