FIX: Imported themes should set their color scheme automatically

This commit is contained in:
David Taylor
2019-01-31 17:45:11 +00:00
parent b3a41878ec
commit 43f3bf71ba
2 changed files with 11 additions and 0 deletions

View File

@@ -177,6 +177,7 @@ class RemoteTheme < ActiveRecord::Base
def update_theme_color_schemes(theme, schemes)
missing_scheme_names = Hash[*theme.color_schemes.pluck(:name, :id).flatten]
ordered_schemes = []
schemes&.each do |name, colors|
missing_scheme_names.delete(name)
@@ -189,12 +190,14 @@ class RemoteTheme < ActiveRecord::Base
theme.notify_color_change(c)
end
end
ordered_schemes << existing
else
scheme = theme.color_schemes.build(name: name)
ColorScheme.base.colors_hashes.each do |color|
override = normalize_override(colors[color[:name]])
scheme.color_scheme_colors << ColorSchemeColor.new(name: color[:name], hex: override || color[:hex])
end
ordered_schemes << scheme
end
end
@@ -202,6 +205,10 @@ class RemoteTheme < ActiveRecord::Base
ColorScheme.where(id: missing_scheme_names.values).delete_all
# we may have stuff pointed at the incorrect scheme?
end
if theme.new_record?
theme.color_scheme = ordered_schemes.first
end
end
def github_diff_link