FIX: Wizard was creating duplicate Light theme if Light was selected (#9464)

This commit is contained in:
Mark VanLandingham 2020-04-20 08:31:43 -05:00 committed by GitHub
parent 7876ee2d67
commit 0a3cc22cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,11 +181,16 @@ class Wizard
next unless scheme_name.present? && ColorScheme.is_base?(scheme_name)
name = I18n.t("color_schemes.#{scheme_name.downcase.gsub(' ', '_')}_theme_name")
theme = nil
scheme = ColorScheme.find_by(base_scheme_id: scheme_name, via_wizard: true)
is_light_theme = (scheme_name == ColorScheme::LIGHT_THEME_ID)
scheme ||= ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: scheme_name)
themes = Theme.where(color_scheme_id: scheme.id).order(:id).to_a
if is_light_theme
themes = (themes || []).concat(Theme.where(color_scheme_id: nil).order(:id).to_a)
themes.sort_by(&:id)
end
theme = themes.find(&:default?)
theme ||= themes.first