From 1128e473c606a6e1bb360c9d33cebac3a394488e Mon Sep 17 00:00:00 2001 From: noellabo Date: Tue, 8 Feb 2022 13:50:44 +0900 Subject: [PATCH] Add setting to hide post count and follow count --- .../activitypub/outboxes_controller.rb | 2 +- .../accounts/follower_accounts_controller.rb | 2 +- .../accounts/following_accounts_controller.rb | 2 +- .../follower_accounts_controller.rb | 10 ++--- .../following_accounts_controller.rb | 10 ++--- .../settings/preferences_controller.rb | 13 +++++- app/helpers/accounts_helper.rb | 20 ++++----- .../mastodon/components/short_number.js | 11 ++++- .../features/account/components/header.js | 14 +++++-- .../directory/components/account_card.js | 7 +++- .../components/account_card.js | 7 +++- .../group_timeline/components/group_detail.js | 10 ++++- app/javascript/mastodon/locales/en.json | 1 + app/javascript/mastodon/locales/ja.json | 1 + app/lib/user_settings_decorator.rb | 29 +++++++++++++ app/models/account.rb | 38 ++++++++++++++--- app/models/concerns/account_settings.rb | 26 ++++++++++++ app/models/user.rb | 21 +++++++++- app/serializers/rest/account_serializer.rb | 12 ++++++ .../activitypub/process_account_service.rb | 1 + app/views/accounts/_header.html.haml | 41 +++++++++++++------ app/views/directories/index.html.haml | 16 ++++++-- app/views/follower_accounts/index.html.haml | 2 +- app/views/following_accounts/index.html.haml | 2 +- app/views/relationships/_account.html.haml | 16 ++++++-- .../settings/preferences/other/show.html.haml | 9 ++++ config/locales/en.yml | 1 + config/locales/ja.yml | 1 + config/locales/simple_form.en.yml | 6 +++ config/locales/simple_form.ja.yml | 6 +++ config/settings.yml | 3 ++ 31 files changed, 274 insertions(+), 66 deletions(-) create mode 100644 app/models/concerns/account_settings.rb diff --git a/app/controllers/activitypub/outboxes_controller.rb b/app/controllers/activitypub/outboxes_controller.rb index b2aab56a5..9bb02af90 100644 --- a/app/controllers/activitypub/outboxes_controller.rb +++ b/app/controllers/activitypub/outboxes_controller.rb @@ -35,7 +35,7 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController ActivityPub::CollectionPresenter.new( id: outbox_url, type: :ordered, - size: @account.statuses_count, + size: @account.public_statuses_count, first: outbox_url(page: true), last: outbox_url(page: true, min_id: 0) ) diff --git a/app/controllers/api/v1/accounts/follower_accounts_controller.rb b/app/controllers/api/v1/accounts/follower_accounts_controller.rb index a665863eb..3fdf356a7 100644 --- a/app/controllers/api/v1/accounts/follower_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/follower_accounts_controller.rb @@ -25,7 +25,7 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController end def hide_results? - @account.suspended? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account)) + @account.suspended? || (@account.hide_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account)) end def default_accounts diff --git a/app/controllers/api/v1/accounts/following_accounts_controller.rb b/app/controllers/api/v1/accounts/following_accounts_controller.rb index 7d885a212..3ffa7695b 100644 --- a/app/controllers/api/v1/accounts/following_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/following_accounts_controller.rb @@ -25,7 +25,7 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController end def hide_results? - @account.suspended? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account)) + @account.suspended? || (@account.hide_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account)) end def default_accounts diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index b3589a39f..eee1a3741 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -15,13 +15,13 @@ class FollowerAccountsController < ApplicationController format.html do expires_in 0, public: true unless user_signed_in? - next if @account.user_hides_network? + next if @account.hide_network? follows end format.json do - raise Mastodon::NotPermittedError if page_requested? && @account.user_hides_network? + raise Mastodon::NotPermittedError if page_requested? && @account.hide_network? expires_in(page_requested? ? 0 : 3.minutes, public: public_fetch_mode?) @@ -65,7 +65,7 @@ class FollowerAccountsController < ApplicationController ActivityPub::CollectionPresenter.new( id: account_followers_url(@account, page: params.fetch(:page, 1)), type: :ordered, - size: @account.followers_count, + size: @account.public_followers_count, items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }, part_of: account_followers_url(@account), next: next_page_url, @@ -75,14 +75,14 @@ class FollowerAccountsController < ApplicationController ActivityPub::CollectionPresenter.new( id: account_followers_url(@account), type: :ordered, - size: @account.followers_count, + size: @account.public_followers_count, first: page_url(1) ) end end def restrict_fields_to - if page_requested? || !@account.user_hides_network? + if page_requested? || !@account.hide_network? # Return all fields else %i(id type total_items) diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb index 8a72dc475..3606961d1 100644 --- a/app/controllers/following_accounts_controller.rb +++ b/app/controllers/following_accounts_controller.rb @@ -15,13 +15,13 @@ class FollowingAccountsController < ApplicationController format.html do expires_in 0, public: true unless user_signed_in? - next if @account.user_hides_network? + next if @account.hide_network? follows end format.json do - raise Mastodon::NotPermittedError if page_requested? && @account.user_hides_network? + raise Mastodon::NotPermittedError if page_requested? && @account.hide_network? expires_in(page_requested? ? 0 : 3.minutes, public: public_fetch_mode?) @@ -65,7 +65,7 @@ class FollowingAccountsController < ApplicationController ActivityPub::CollectionPresenter.new( id: account_following_index_url(@account, page: params.fetch(:page, 1)), type: :ordered, - size: @account.following_count, + size: @account.public_following_count, items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }, part_of: account_following_index_url(@account), next: next_page_url, @@ -75,14 +75,14 @@ class FollowingAccountsController < ApplicationController ActivityPub::CollectionPresenter.new( id: account_following_index_url(@account), type: :ordered, - size: @account.following_count, + size: @account.public_following_count, first: page_url(1) ) end end def restrict_fields_to - if page_requested? || !@account.user_hides_network? + if page_requested? || !@account.hide_network? # Return all fields else %i(id type total_items) diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 45ca404a5..319636499 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -1,10 +1,14 @@ # frozen_string_literal: true class Settings::PreferencesController < Settings::BaseController + before_action :set_account, only: [:update] + def show; end def update - user_settings.update(user_settings_params.to_h) + if user_settings.update(user_settings_params.to_h) + ActivityPub::UpdateDistributionWorker.perform_async(@account.id) + end if current_user.update(user_params) I18n.locale = current_user.locale @@ -69,8 +73,15 @@ class Settings::PreferencesController < Settings::BaseController :setting_enable_limited_timeline, :setting_enable_reaction, :setting_show_reply_tree_button, + :setting_hide_statuses_count, + :setting_hide_following_count, + :setting_hide_followers_count, notification_emails: %i(follow follow_request reblog favourite emoji_reaction mention digest report pending_account trending_tag), interactions: %i(must_be_follower must_be_following must_be_following_dm) ) end + + def set_account + @account = current_account + end end diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index db3da2b05..fc307ec70 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -79,21 +79,21 @@ module AccountsHelper def account_description(account) prepend_str = [ - [ - number_to_human(account.statuses_count, precision: 3, strip_insignificant_zeros: true), - I18n.t('accounts.posts', count: account.statuses_count), + account.hide_statuses_count? ? nil : [ + number_to_human(account.public_statuses_count, precision: 3, strip_insignificant_zeros: true), + I18n.t('accounts.posts', count: account.public_statuses_count), ].join(' '), - [ - number_to_human(account.following_count, precision: 3, strip_insignificant_zeros: true), - I18n.t('accounts.following', count: account.following_count), + account.hide_following_count? ? nil : [ + number_to_human(account.public_following_count, precision: 3, strip_insignificant_zeros: true), + I18n.t('accounts.following', count: account.public_following_count), ].join(' '), - [ - number_to_human(account.followers_count, precision: 3, strip_insignificant_zeros: true), - I18n.t('accounts.followers', count: account.followers_count), + account.hide_followers_count? ? nil : [ + number_to_human(account.public_followers_count, precision: 3, strip_insignificant_zeros: true), + I18n.t('accounts.followers', count: account.public_followers_count), ].join(' '), - ].join(', ') + ].compact.join(', ') [prepend_str, account.note].join(' · ') end diff --git a/app/javascript/mastodon/components/short_number.js b/app/javascript/mastodon/components/short_number.js index 535c17727..bb0f54d19 100644 --- a/app/javascript/mastodon/components/short_number.js +++ b/app/javascript/mastodon/components/short_number.js @@ -14,6 +14,7 @@ import { FormattedMessage, FormattedNumber } from 'react-intl'; /** * @typedef {object} ShortNumberProps * @property {number} value Number to display in short variant + * @property {boolean} hide Hide the number * @property {ShortNumberRenderer} [renderer] * Custom renderer for numbers, provided as a prop. If another renderer * passed as a child of this component, this prop won't be used. @@ -28,7 +29,8 @@ import { FormattedMessage, FormattedNumber } from 'react-intl'; * @param {ShortNumberProps} param0 Props for the component * @returns {JSX.Element} Rendered number */ -function ShortNumber({ value, renderer, children }) { +function ShortNumber({ value, hide, renderer, children }) { + value = hide ? 0 : value; const shortNumber = toShortNumber(value); const [, division] = shortNumber; @@ -40,7 +42,7 @@ function ShortNumber({ value, renderer, children }) { // eslint-disable-next-line eqeqeq const customRenderer = children != null ? children : renderer; - const displayNumber = ; + const displayNumber = hide ? '-' : ; // eslint-disable-next-line eqeqeq return customRenderer != null @@ -50,10 +52,15 @@ function ShortNumber({ value, renderer, children }) { ShortNumber.propTypes = { value: PropTypes.number.isRequired, + hide: PropTypes.bool, renderer: PropTypes.func, children: PropTypes.func, }; +ShortNumber.defaultProps = { + hide: false, +}; + /** * @typedef {object} ShortNumberCounterProps * @property {import('../utils/number').ShortNumber} value Short number diff --git a/app/javascript/mastodon/features/account/components/header.js b/app/javascript/mastodon/features/account/components/header.js index 080a5739f..df7e936ef 100644 --- a/app/javascript/mastodon/features/account/components/header.js +++ b/app/javascript/mastodon/features/account/components/header.js @@ -54,6 +54,7 @@ const messages = defineMessages({ add_or_remove_from_list: { id: 'account.add_or_remove_from_list', defaultMessage: 'Add or Remove from lists' }, add_or_remove_from_circle: { id: 'account.add_or_remove_from_circle', defaultMessage: 'Add or Remove from circles' }, admin_account: { id: 'status.admin_account', defaultMessage: 'Open moderation interface for @{name}' }, + secret: { id: 'account.secret', defaultMessage: 'Secret' }, }); const dateFormatOptions = { @@ -333,6 +334,10 @@ class Header extends ImmutablePureComponent { buttons = {subscribing_buttons}{following_buttons}; } + const hide_statuses_count = account.getIn(['other_settings', 'hide_statuses_count'], false); + const hide_following_count = account.getIn(['other_settings', 'hide_following_count'], false); + const hide_followers_count = account.getIn(['other_settings', 'hide_followers_count'], false); + return (
@@ -408,22 +413,25 @@ class Header extends ImmutablePureComponent { {!suspended && (
- + - + - + diff --git a/app/javascript/mastodon/features/directory/components/account_card.js b/app/javascript/mastodon/features/directory/components/account_card.js index 18b5fcbc8..c50d8ad85 100644 --- a/app/javascript/mastodon/features/directory/components/account_card.js +++ b/app/javascript/mastodon/features/directory/components/account_card.js @@ -272,6 +272,9 @@ class AccountCard extends ImmutablePureComponent { } } + const hide_statuses_count = account.getIn(['other_settings', 'hide_statuses_count'], false); + const hide_followers_count = account.getIn(['other_settings', 'hide_followers_count'], false); + return (
@@ -307,13 +310,13 @@ class AccountCard extends ImmutablePureComponent {
- + {hide_statuses_count ? '-' : }
- {' '} + {hide_followers_count ? '-' : }{' '}
@@ -322,13 +325,13 @@ class AccountCard extends ImmutablePureComponent {
- + {hide_statuses_count ? '-' : }
- {' '} + {hide_followers_count ? '-' : }{' '} { @@ -286,6 +287,9 @@ class GroupDetail extends ImmutablePureComponent { } } + const hide_statuses_count = account.getIn(['other_settings', 'hide_statuses_count'], false); + const hide_followers_count = account.getIn(['other_settings', 'hide_followers_count'], false); + return (
@@ -317,14 +321,16 @@ class GroupDetail extends ImmutablePureComponent {
- + - + diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 71d7a73c2..0369d2f1c 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -42,6 +42,7 @@ "account.posts_with_replies": "Posts and replies", "account.report": "Report @{name}", "account.requested": "Awaiting approval. Click to cancel follow request", + "account.secret": "Secret", "account.share": "Share @{name}'s profile", "account.show_reblogs": "Show boosts from @{name}", "account.statuses_counter": "{count, plural, one {{counter} Post} other {{counter} Posts}}", diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index e4b9cfe87..18faf3862 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -40,6 +40,7 @@ "account.open_domain_timeline": "{domain}タイムラインを表示", "account.posts": "投稿", "account.posts_with_replies": "投稿と返信", + "account.secret": "非公開", "account.report": "@{name}さんを通報", "account.requested": "フォロー承認待ちです。クリックしてキャンセル", "account.share": "@{name}さんのプロフィールを共有する", diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index a77393672..be0f22b96 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -10,10 +10,24 @@ class UserSettingsDecorator def update(settings) @settings = settings process_update + profile_change? end private + PROFILE_KEYS = %w( + setting_noindex + setting_hide_network + setting_hide_statuses_count + setting_hide_following_count + setting_hide_followers_count + setting_enable_reaction + ).freeze + + def profile_change? + settings.keys.intersection(PROFILE_KEYS).any? + end + def process_update user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails') user.settings['interactions'] = merged_interactions if change?('interactions') @@ -53,6 +67,9 @@ class UserSettingsDecorator user.settings['enable_limited_timeline'] = enable_limited_timeline_preference if change?('setting_enable_limited_timeline') user.settings['enable_reaction'] = enable_reaction_preference if change?('setting_enable_reaction') user.settings['show_reply_tree_button'] = show_reply_tree_button_preference if change?('setting_show_reply_tree_button') + user.settings['hide_statuses_count'] = hide_statuses_count_preference if change?('setting_hide_statuses_count') + user.settings['hide_following_count'] = hide_following_count_preference if change?('setting_hide_following_count') + user.settings['hide_followers_count'] = hide_followers_count_preference if change?('setting_hide_followers_count') end def merged_notification_emails @@ -207,6 +224,18 @@ class UserSettingsDecorator boolean_cast_setting 'setting_show_reply_tree_button' end + def hide_statuses_count_preference + boolean_cast_setting 'setting_hide_statuses_count' + end + + def hide_following_count_preference + boolean_cast_setting 'setting_hide_following_count' + end + + def hide_followers_count_preference + boolean_cast_setting 'setting_hide_followers_count' + end + def boolean_cast_setting(key) ActiveModel::Type::Boolean.new.cast(settings[key]) end diff --git a/app/models/account.rb b/app/models/account.rb index 623e25d67..8105c4ddc 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -74,6 +74,7 @@ class Account < ApplicationRecord include DomainNormalizable include DomainMaterializable include AccountMerging + include AccountSettings TRUST_LEVELS = { untrusted: 0, @@ -137,7 +138,11 @@ class Account < ApplicationRecord :moderator?, :staff?, :locale, - :hides_network?, + :noindex?, + :hide_network?, + :hide_statuses_count?, + :hide_followers_count?, + :hide_following_count?, :shows_application?, to: :user, prefix: true, @@ -187,6 +192,18 @@ class Account < ApplicationRecord "#{username}@#{Rails.configuration.x.local_domain}" end + def public_statuses_count + hide_statuses_count? ? 0 : statuses_count + end + + def public_followers_count + hide_followers_count? ? 0 : followers_count + end + + def public_following_count + hide_following_count? ? 0 : following_count + end + def local_followers_count Follow.where(target_account_id: id).count end @@ -351,12 +368,12 @@ class Account < ApplicationRecord save! end - def hides_followers? - hide_collections? || user_hides_network? + def hide_followers? + hide_collections? || hide_network? end - def hides_following? - hide_collections? || user_hides_network? + def hide_following? + hide_collections? || hide_network? end def object_type @@ -402,7 +419,16 @@ class Account < ApplicationRecord end def other_settings - settings + local? && user ? settings.merge( + { + 'noindex' => user.setting_noindex, + 'hide_network' => user.setting_hide_network, + 'hide_statuses_count' => user.setting_hide_statuses_count, + 'hide_following_count' => user.setting_hide_following_count, + 'hide_followers_count' => user.setting_hide_followers_count, + 'enable_reaction' => user.setting_enable_reaction, + } + ) : settings end class Field < ActiveModelSerializers::Model diff --git a/app/models/concerns/account_settings.rb b/app/models/concerns/account_settings.rb new file mode 100644 index 000000000..11aa79a6f --- /dev/null +++ b/app/models/concerns/account_settings.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module AccountSettings + extend ActiveSupport::Concern + + def noindex? + local? ? user&.noindex? : settings['noindex'] + end + + def hide_network? + local? ? user&.hide_network? : settings['hide_network'] + end + + def hide_statuses_count? + local? ? user&.hide_statuses_count? : settings['hide_statuses_count'] + end + + def hide_following_count? + local? ? user&.hide_following_count? : settings['hide_following_count'] + end + + def hide_followers_count? + local? ? user&.hide_followers_count? : settings['hide_followers_count'] + end + +end diff --git a/app/models/user.rb b/app/models/user.rb index c24657a74..c0325ebd8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,6 +131,7 @@ class User < ApplicationRecord :follow_button_to_list_adder, :show_navigation_panel, :show_quote_button, :show_bookmark_button, :place_tab_bar_at_bottom,:show_tab_bar_label, :enable_limited_timeline, :enable_reaction, :show_reply_tree_button, + :hide_statuses_count, :hide_following_count, :hide_followers_count, to: :settings, prefix: :setting, allow_nil: false @@ -271,8 +272,24 @@ class User < ApplicationRecord settings.notification_emails['trending_tag'] end - def hides_network? - @hides_network ||= settings.hide_network + def noindex? + @noindex ||= settings.noindex + end + + def hide_network? + @hide_network ||= settings.hide_network + end + + def hide_statuses_count? + @hide_statuses_count ||= settings.hide_statuses_count + end + + def hide_following_count? + @hide_following_count ||= settings.hide_following_count + end + + def hide_followers_count? + @hide_followers_count ||= settings.hide_followers_count end def aggregates_reblogs? diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 182007bf7..73af4c4b0 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -64,6 +64,18 @@ class REST::AccountSerializer < ActiveModel::Serializer object.last_status_at&.to_date&.iso8601 end + def statuses_count + object.public_statuses_count + end + + def following_count + object.public_following_count + end + + def followers_count + object.public_followers_count + end + def display_name object.suspended? ? '' : object.display_name end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 1e818cf7e..4c8f9ee4f 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -213,6 +213,7 @@ class ActivityPub::ProcessAccountService < BaseService end DEFER_SETTINGS_KEYS = %w( + noindex ).freeze def defer_settings diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index d9966723a..7f5da8c19 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -14,19 +14,34 @@ .public-account-header__tabs__tabs .details-counters .counter{ class: active_nav_class(short_account_url(account), short_account_with_replies_url(account), short_account_media_url(account)) } - = link_to short_account_url(account), class: 'u-url u-uid', title: number_with_delimiter(account.statuses_count) do - %span.counter-number= friendly_number_to_human account.statuses_count - %span.counter-label= t('accounts.posts', count: account.statuses_count) + - if account.hide_statuses_count? + = link_to short_account_url(account), class: 'u-url u-uid', title: t('accounts.secret') do + %span.counter-number= '-' + %span.counter-label= t('accounts.posts', count: 0) + - else + = link_to short_account_url(account), class: 'u-url u-uid', title: number_with_delimiter(account.public_statuses_count) do + %span.counter-number= friendly_number_to_human account.public_statuses_count + %span.counter-label= t('accounts.posts', count: account.public_statuses_count) .counter{ class: active_nav_class(account_following_index_url(account)) } - = link_to account_following_index_url(account), title: number_with_delimiter(account.following_count) do - %span.counter-number= friendly_number_to_human account.following_count - %span.counter-label= t('accounts.following', count: account.following_count) + - if account.hide_following_count? + = link_to account_following_index_url(account), title: t('accounts.secret') do + %span.counter-number= '-' + %span.counter-label= t('accounts.following', count: 0) + - else + = link_to account_following_index_url(account), title: number_with_delimiter(account.public_following_count) do + %span.counter-number= friendly_number_to_human account.public_following_count + %span.counter-label= t('accounts.following', count: account.public_following_count) .counter{ class: active_nav_class(account_followers_url(account)) } - = link_to account_followers_url(account), title: number_with_delimiter(account.followers_count) do - %span.counter-number= friendly_number_to_human account.followers_count - %span.counter-label= t('accounts.followers', count: account.followers_count) + - if account.hide_followers_count? + = link_to account_followers_url(account), title: t('accounts.secret') do + %span.counter-number= '-' + %span.counter-label= t('accounts.followers', count: 0) + - else + = link_to account_followers_url(account), title: number_with_delimiter(account.public_followers_count) do + %span.counter-number= friendly_number_to_human account.public_followers_count + %span.counter-label= t('accounts.followers', count: account.public_followers_count) .spacer .public-account-header__tabs__tabs__buttons = account_action_button(account) @@ -36,8 +51,8 @@ .public-account-header__extra__links = link_to account_following_index_url(account) do - %strong= friendly_number_to_human account.following_count - = t('accounts.following', count: account.following_count) + %strong= friendly_number_to_human account.public_following_count + = t('accounts.following', count: account.public_following_count) = link_to account_followers_url(account) do - %strong= friendly_number_to_human account.followers_count - = t('accounts.followers', count: account.followers_count) + %strong= friendly_number_to_human account.public_followers_count + = t('accounts.followers', count: account.public_followers_count) diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index 04639e32c..56c151fb3 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -39,11 +39,19 @@ .directory__card__extra .accounts-table__count - = friendly_number_to_human account.statuses_count - %small= t('accounts.posts', count: account.statuses_count).downcase + - if account.hide_statuses_count? + = '-' + %small= t('accounts.posts', count: 0).downcase + - else + = friendly_number_to_human account.public_statuses_count + %small= t('accounts.posts', count: account.public_statuses_count).downcase .accounts-table__count - = friendly_number_to_human account.followers_count - %small= t('accounts.followers', count: account.followers_count).downcase + - if account.hide_followers_count? + = '-' + %small= t('accounts.followers', count: 0).downcase + - else + = friendly_number_to_human account.public_followers_count + %small= t('accounts.followers', count: account.public_followers_count).downcase .accounts-table__count - if account.last_status_at.present? %time.time-ago{ datetime: account.last_status_at.to_date.iso8601, title: l(account.last_status_at.to_date) }= l account.last_status_at.to_date diff --git a/app/views/follower_accounts/index.html.haml b/app/views/follower_accounts/index.html.haml index 645dd2de1..e0a22412e 100644 --- a/app/views/follower_accounts/index.html.haml +++ b/app/views/follower_accounts/index.html.haml @@ -7,7 +7,7 @@ = render 'accounts/header', account: @account -- if @account.user_hides_network? +- if @account.hide_network? .nothing-here= t('accounts.network_hidden') - elsif user_signed_in? && @account.blocking?(current_account) .nothing-here= t('accounts.unavailable') diff --git a/app/views/following_accounts/index.html.haml b/app/views/following_accounts/index.html.haml index 17fe79018..6882deb47 100644 --- a/app/views/following_accounts/index.html.haml +++ b/app/views/following_accounts/index.html.haml @@ -7,7 +7,7 @@ = render 'accounts/header', account: @account -- if @account.user_hides_network? +- if @account.hide_network? .nothing-here= t('accounts.network_hidden') - elsif user_signed_in? && @account.blocking?(current_account) .nothing-here= t('accounts.unavailable') diff --git a/app/views/relationships/_account.html.haml b/app/views/relationships/_account.html.haml index 0fa3cffb5..d0ca1304b 100644 --- a/app/views/relationships/_account.html.haml +++ b/app/views/relationships/_account.html.haml @@ -9,11 +9,19 @@ = interrelationships_icon(@relationships, account.id) %td= account_link_to account %td.accounts-table__count.optional - = friendly_number_to_human account.statuses_count - %small= t('accounts.posts', count: account.statuses_count).downcase + - if account.hide_statuses_count? + = '-' + %small= t('accounts.posts', count: 0) + - else + = friendly_number_to_human account.public_statuses_count + %small= t('accounts.posts', count: account.public_statuses_count).downcase %td.accounts-table__count.optional - = friendly_number_to_human account.followers_count - %small= t('accounts.followers', count: account.followers_count).downcase + - if account.hide_followers_count? + = '-' + %small= t('accounts.followers', count: 0) + - else + = friendly_number_to_human account.public_followers_count + %small= t('accounts.followers', count: account.public_followers_count).downcase %td.accounts-table__count - if account.last_status_at.present? %time.time-ago{ datetime: account.last_status_at.to_date.iso8601, title: l(account.last_status_at.to_date) }= l account.last_status_at diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index b7710350e..131064e2e 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -13,6 +13,15 @@ .fields-group = f.input :setting_hide_network, as: :boolean, wrapper: :with_label + .fields-group + = f.input :setting_hide_statuses_count, as: :boolean, wrapper: :with_label, fedibird_features: true + + .fields-group + = f.input :setting_hide_following_count, as: :boolean, wrapper: :with_label, fedibird_features: true + + .fields-group + = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label, fedibird_features: true + .fields-group = f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true diff --git a/config/locales/en.yml b/config/locales/en.yml index dece3f40e..4c0cf38a0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,6 +85,7 @@ en: bot: Bot group: Group moderator: Mod + secret: Secret unavailable: Profile unavailable unfollow: Unfollow account_subscribes: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index a457e665a..5c11b9c8d 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -79,6 +79,7 @@ ja: bot: Bot group: Group moderator: Mod + secret: 非公開 unavailable: プロフィールは利用できません unfollow: フォロー解除 account_subscribes: diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index d0971a722..dd26a514c 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -55,7 +55,10 @@ en: setting_enable_limited_timeline: Enable a limited home to display private and circle and direct message setting_enable_reaction: Enable the reaction display on the timeline and display the reaction button setting_follow_button_to_list_adder: Change the behavior of the Follow / Subscribe button, open a dialog where you can select a list to follow / subscribe, or opt out of receiving at home + setting_hide_followers_count: The number of followers will be hidden in your profile + setting_hide_following_count: The number of following will be hidden in your profile setting_hide_network: Who you follow and who follows you will be hidden on your profile + setting_hide_statuses_count: The number of post will be hidden in your profile setting_noindex: Affects your public profile and post pages setting_place_tab_bar_at_bottom: When using a touch device, you can operate tabs within the reach of your fingers. setting_show_application: The application you use to post will be displayed in the detailed view of your posts @@ -194,7 +197,10 @@ en: setting_enable_reaction: Enable reaction setting_expand_spoilers: Always expand posts marked with content warnings setting_follow_button_to_list_adder: Open list add dialog with follow button + setting_hide_followers_count: Hide your followers count + setting_hide_following_count: Hide your following count setting_hide_network: Hide your social graph + setting_hide_statuses_count: Hide your post count setting_noindex: Opt-out of search engine indexing setting_place_tab_bar_at_bottom: Place the tab bar at the bottom setting_reduce_motion: Reduce motion in animations diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index e7a5b3b7c..5ca748e04 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -55,7 +55,10 @@ ja: setting_enable_limited_timeline: フォロワー限定・サークル・ダイレクトメッセージを表示する限定ホームを有効にします setting_enable_reaction: タイムラインでリアクションの表示を有効にし、リアクションボタンを表示する setting_follow_button_to_list_adder: フォロー・購読ボタンの動作を変更し、フォロー・購読するリストを選択したり、ホームで受け取らないよう設定するダイアログを開きます + setting_hide_followers_count: フォロワー数をプロフィールページで見られないようにします + setting_hide_following_count: フォロー数をプロフィールページで見られないようにします setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします + setting_hide_statuses_count: 投稿数をプロフィールページで見られないようにします setting_noindex: 公開プロフィールおよび各投稿ページに影響します setting_place_tab_bar_at_bottom: タッチデバイス使用時に、タブの操作を指の届く範囲で行えます setting_show_application: 投稿するのに使用したアプリが投稿の詳細ビューに表示されるようになります @@ -194,7 +197,10 @@ ja: setting_enable_reaction: リアクションを有効にする setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する setting_follow_button_to_list_adder: フォローボタンでリスト追加ダイアログを開く + setting_hide_followers_count: フォロワー数を隠す + setting_hide_following_count: フォロー数を隠す setting_hide_network: 繋がりを隠す + setting_hide_statuses_count: 投稿数を隠す setting_noindex: 検索エンジンによるインデックスを拒否する setting_place_tab_bar_at_bottom: タブバーを下に配置する setting_reduce_motion: アニメーションの動きを減らす diff --git a/config/settings.yml b/config/settings.yml index 2213b552b..07b654276 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -52,6 +52,9 @@ defaults: &defaults enable_limited_timeline: false enable_reaction: true show_reply_tree_button: true + hide_statuses_count: false + hide_following_count: false + hide_followers_count: false notification_emails: follow: false reblog: false