Merge pull request #1678 from ClearlyClaire/glitch-soc/fixes/robust-theme-fallback

Make theme-selection fall back to default ones if configured is not found
This commit is contained in:
Claire 2022-02-05 13:24:05 +01:00 committed by GitHub
commit 24d1ddcc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -136,16 +136,6 @@ class ApplicationController < ActionController::Base
@current_session = SessionActivation.find_by(session_id: cookies.signed['_session_id']) if cookies.signed['_session_id'].present?
end
def current_flavour
return Setting.flavour unless Themes.instance.flavours.include? current_user&.setting_flavour
current_user.setting_flavour
end
def current_skin
return Setting.skin unless Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin
current_user.setting_skin
end
def respond_with_error(code)
respond_to do |format|
format.any do

View File

@ -10,6 +10,15 @@ module ThemingConcern
private
def current_flavour
[current_user&.setting_flavour, Setting.flavour, 'glitch', 'vanilla'].find { |flavour| Themes.instance.flavours.include?(flavour) }
end
def current_skin
skins = Themes.instance.skins_for(current_flavour)
[current_user&.setting_skin, Setting.skin, 'default'].find { |skin| skins.include?(skin) }
end
def valid_pack_data?(data, pack_name)
data['pack'].is_a?(Hash) && [String, Hash].any? { |c| data['pack'][pack_name].is_a?(c) }
end