mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-10 09:29:18 +00:00
18d3fa953b
* add a system_font_ui setting on the server * Plug the system_font_ui on the front-end * add EN/FR locales for the new setting * put Roboto after all other fonts * remove trailing whitespace so CodeClimate is happy * fix user_spec.rb * correctly write user_spect this time * slightly better way of adding the classes * add comments to the system-font stack for clarification * use .system-font for the class instead * don't use multiple lines for comments * remove trailing whitespace * use the classnames module for consistency * use `mastodon-font-sans-serif` instead of Roboto directly
67 lines
1.6 KiB
Ruby
67 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class UserSettingsDecorator
|
|
attr_reader :user, :settings
|
|
|
|
def initialize(user)
|
|
@user = user
|
|
end
|
|
|
|
def update(settings)
|
|
@settings = settings
|
|
process_update
|
|
end
|
|
|
|
private
|
|
|
|
def process_update
|
|
user.settings['notification_emails'] = merged_notification_emails
|
|
user.settings['interactions'] = merged_interactions
|
|
user.settings['default_privacy'] = default_privacy_preference
|
|
user.settings['boost_modal'] = boost_modal_preference
|
|
user.settings['delete_modal'] = delete_modal_preference
|
|
user.settings['auto_play_gif'] = auto_play_gif_preference
|
|
user.settings['system_font_ui'] = system_font_ui_preference
|
|
end
|
|
|
|
def merged_notification_emails
|
|
user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h
|
|
end
|
|
|
|
def merged_interactions
|
|
user.settings['interactions'].merge coerced_settings('interactions').to_h
|
|
end
|
|
|
|
def default_privacy_preference
|
|
settings['setting_default_privacy']
|
|
end
|
|
|
|
def boost_modal_preference
|
|
boolean_cast_setting 'setting_boost_modal'
|
|
end
|
|
|
|
def delete_modal_preference
|
|
boolean_cast_setting 'setting_delete_modal'
|
|
end
|
|
|
|
def system_font_ui_preference
|
|
boolean_cast_setting 'setting_system_font_ui'
|
|
end
|
|
|
|
def auto_play_gif_preference
|
|
boolean_cast_setting 'setting_auto_play_gif'
|
|
end
|
|
|
|
def boolean_cast_setting(key)
|
|
settings[key] == '1'
|
|
end
|
|
|
|
def coerced_settings(key)
|
|
coerce_values settings.fetch(key, {})
|
|
end
|
|
|
|
def coerce_values(params_hash)
|
|
params_hash.transform_values { |x| x == '1' }
|
|
end
|
|
end
|