forked from treehouse/mastodon
Add a per-user setting to hide followers count
This is only available if the instance-wide setting isn't set and allows people to hide their own followers count. This does not hide others' to them.signup-info-prompt
parent
9e04b2e8a4
commit
bd23288a52
|
@ -37,7 +37,7 @@ class FollowerAccountsController < ApplicationController
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
options = { type: :ordered }
|
options = { type: :ordered }
|
||||||
options[:size] = @account.followers_count unless Setting.hide_followers_count
|
options[:size] = @account.followers_count unless Setting.hide_followers_count || @account.user&.setting_hide_followers_count
|
||||||
if params[:page].present?
|
if params[:page].present?
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_followers_url(@account, page: params.fetch(:page, 1)),
|
id: account_followers_url(@account, page: params.fetch(:page, 1)),
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_system_font_ui,
|
:setting_system_font_ui,
|
||||||
:setting_noindex,
|
:setting_noindex,
|
||||||
:setting_hide_network,
|
:setting_hide_network,
|
||||||
|
:setting_hide_followers_count,
|
||||||
:setting_aggregate_reblogs,
|
:setting_aggregate_reblogs,
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention digest report),
|
notification_emails: %i(follow follow_request reblog favourite mention digest report),
|
||||||
interactions: %i(must_be_follower must_be_following)
|
interactions: %i(must_be_follower must_be_following)
|
||||||
|
|
|
@ -73,7 +73,7 @@ module StreamEntriesHelper
|
||||||
].join(' '),
|
].join(' '),
|
||||||
]
|
]
|
||||||
|
|
||||||
unless Setting.hide_followers_count
|
unless Setting.hide_followers_count || account.user&.setting_hide_followers_count
|
||||||
prepend_stats << [
|
prepend_stats << [
|
||||||
number_to_human(account.followers_count, strip_insignificant_zeros: true),
|
number_to_human(account.followers_count, strip_insignificant_zeros: true),
|
||||||
I18n.t('accounts.followers', count: account.followers_count),
|
I18n.t('accounts.followers', count: account.followers_count),
|
||||||
|
|
|
@ -30,6 +30,7 @@ class UserSettingsDecorator
|
||||||
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
||||||
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
||||||
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
||||||
|
user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count')
|
||||||
user.settings['flavour'] = flavour_preference if change?('setting_flavour')
|
user.settings['flavour'] = flavour_preference if change?('setting_flavour')
|
||||||
user.settings['skin'] = skin_preference if change?('setting_skin')
|
user.settings['skin'] = skin_preference if change?('setting_skin')
|
||||||
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
|
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
|
||||||
|
@ -92,6 +93,10 @@ class UserSettingsDecorator
|
||||||
boolean_cast_setting 'setting_noindex'
|
boolean_cast_setting 'setting_noindex'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_followers_count_preference
|
||||||
|
boolean_cast_setting 'setting_hide_followers_count'
|
||||||
|
end
|
||||||
|
|
||||||
def flavour_preference
|
def flavour_preference
|
||||||
settings['setting_flavour']
|
settings['setting_flavour']
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,7 +94,7 @@ class User < ApplicationRecord
|
||||||
has_many :session_activations, dependent: :destroy
|
has_many :session_activations, dependent: :destroy
|
||||||
|
|
||||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
|
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
|
||||||
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network,
|
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
|
||||||
:expand_spoilers, :default_language, :aggregate_reblogs, to: :settings, prefix: :setting, allow_nil: false
|
:expand_spoilers, :default_language, :aggregate_reblogs, to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
attr_reader :invite_code
|
attr_reader :invite_code
|
||||||
|
|
|
@ -53,6 +53,6 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers_count
|
def followers_count
|
||||||
Setting.hide_followers_count ? -1 : object.followers_count
|
(Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
%span.counter-label= t('accounts.following', count: account.following_count)
|
%span.counter-label= t('accounts.following', count: account.following_count)
|
||||||
|
|
||||||
.counter{ class: active_nav_class(account_followers_url(account)) }
|
.counter{ class: active_nav_class(account_followers_url(account)) }
|
||||||
= link_to account_followers_url(account), title: Setting.hide_followers_count ? nil : number_with_delimiter(account.followers_count) do
|
= link_to account_followers_url(account), title: (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? nil : number_with_delimiter(account.followers_count) do
|
||||||
%span.counter-number= Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
%span.counter-number= (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
||||||
%span.counter-label= t('accounts.followers', count: account.followers_count)
|
%span.counter-label= t('accounts.followers', count: account.followers_count)
|
||||||
.spacer
|
.spacer
|
||||||
.public-account-header__tabs__tabs__buttons
|
.public-account-header__tabs__tabs__buttons
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
= number_to_human account.statuses_count, strip_insignificant_zeros: true
|
= number_to_human account.statuses_count, strip_insignificant_zeros: true
|
||||||
%small= t('accounts.posts', count: account.statuses_count).downcase
|
%small= t('accounts.posts', count: account.statuses_count).downcase
|
||||||
%td.accounts-table__count.optional
|
%td.accounts-table__count.optional
|
||||||
= Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
= (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
||||||
%small= t('accounts.followers', count: account.followers_count).downcase
|
%small= t('accounts.followers', count: account.followers_count).downcase
|
||||||
%td.accounts-table__count
|
%td.accounts-table__count
|
||||||
- if account.last_status_at.present?
|
- if account.last_status_at.present?
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label
|
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
|
- unless Setting.hide_followers_count
|
||||||
|
.fields-group
|
||||||
|
= f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
%hr#settings_web/
|
%hr#settings_web/
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -79,6 +79,7 @@ en:
|
||||||
setting_display_media_show_all: Show all
|
setting_display_media_show_all: Show all
|
||||||
setting_expand_spoilers: Always expand toots marked with content warnings
|
setting_expand_spoilers: Always expand toots marked with content warnings
|
||||||
setting_favourite_modal: Show confirmation dialog before favouriting (applies to Glitch flavour only)
|
setting_favourite_modal: Show confirmation dialog before favouriting (applies to Glitch flavour only)
|
||||||
|
setting_hide_followers_count: Hide your followers count
|
||||||
setting_hide_network: Hide your network
|
setting_hide_network: Hide your network
|
||||||
setting_noindex: Opt-out of search engine indexing
|
setting_noindex: Opt-out of search engine indexing
|
||||||
setting_reduce_motion: Reduce motion in animations
|
setting_reduce_motion: Reduce motion in animations
|
||||||
|
|
Loading…
Reference in New Issue