Change “privacy and reach” settings so that unchecking boxes always increase privacy and checking them always increase reach (#26508)

This commit is contained in:
Claire
2023-08-17 09:13:26 +02:00
committed by GitHub
parent 0446394465
commit cc4560d95b
4 changed files with 20 additions and 7 deletions

View File

@ -18,7 +18,7 @@ class Settings::PrivacyController < Settings::BaseController
private
def account_params
params.require(:account).permit(:discoverable, :locked, :hide_collections, settings: UserSettings.keys)
params.require(:account).permit(:discoverable, :unlocked, :show_collections, settings: UserSettings.keys)
end
def set_account

View File

@ -442,8 +442,21 @@ class Account < ApplicationRecord
EntityCache.instance.mention(username, domain)
end
end
def inverse_alias(key, original_key)
define_method("#{key}=") do |value|
public_send("#{original_key}=", !ActiveModel::Type::Boolean.new.cast(value))
end
define_method(key) do
!public_send(original_key)
end
end
end
inverse_alias :show_collections, :hide_collections
inverse_alias :unlocked, :locked
def emojis
@emojis ||= CustomEmoji.from_text(emojifiable_text, domain)
end

View File

@ -18,7 +18,7 @@
= f.input :discoverable, as: :boolean, wrapper: :with_label, recommended: true
.fields-group
= f.input :locked, as: :boolean, wrapper: :with_label
= f.input :unlocked, as: :boolean, wrapper: :with_label
%h4= t('privacy.search')
@ -33,7 +33,7 @@
%p.lead= t('privacy.privacy_hint_html')
.fields-group
= f.input :hide_collections, as: :boolean, wrapper: :with_label
= f.input :show_collections, as: :boolean, wrapper: :with_label
= f.simple_fields_for :settings, current_user.settings do |ff|
.fields-group