mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-14 04:03:59 -05:00
6fcb870d96
If a flavour has only one skin, the skin selector will be omitted. This omits the user[setting_skin] field, and because that's the only user[...] field on the page, the entire user object will not be present in the request handler's params object. This commit accounts for that scenario by avoiding params.require(:user) and instead picking out what we need from the params hash.
35 lines
834 B
Ruby
35 lines
834 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Settings::FlavoursController < Settings::BaseController
|
|
|
|
def index
|
|
redirect_to action: 'show', flavour: current_flavour
|
|
end
|
|
|
|
def show
|
|
unless Themes.instance.flavours.include?(params[:flavour]) or params[:flavour] == current_flavour
|
|
redirect_to action: 'show', flavour: current_flavour
|
|
end
|
|
|
|
@listing = Themes.instance.flavours
|
|
@selected = params[:flavour]
|
|
end
|
|
|
|
def update
|
|
user_settings.update(user_settings_params(params[:flavour]))
|
|
redirect_to action: 'show', flavour: params[:flavour]
|
|
end
|
|
|
|
private
|
|
|
|
def user_settings
|
|
UserSettingsDecorator.new(current_user)
|
|
end
|
|
|
|
def user_settings_params(flavour)
|
|
{ setting_flavour: params.require(:flavour),
|
|
setting_skin: params.dig(:user, :setting_skin)
|
|
}.with_indifferent_access
|
|
end
|
|
end
|