From 9b06c0f24a2d3fb5a453611fe8e1c938e2351e5a Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 9 Nov 2023 13:58:02 +0100 Subject: [PATCH] Fix Web UI not displaying appropriate explanation when a user hides their follows/followers (#27791) --- app/javascript/mastodon/api_types/accounts.ts | 1 + app/javascript/mastodon/features/followers/index.jsx | 5 ++++- app/javascript/mastodon/features/following/index.jsx | 5 ++++- app/javascript/mastodon/locales/en.json | 1 + app/javascript/mastodon/models/account.ts | 1 + app/serializers/rest/account_serializer.rb | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/api_types/accounts.ts b/app/javascript/mastodon/api_types/accounts.ts index ce55dc604a..985abf9463 100644 --- a/app/javascript/mastodon/api_types/accounts.ts +++ b/app/javascript/mastodon/api_types/accounts.ts @@ -42,4 +42,5 @@ export interface ApiAccountJSON { suspended?: boolean; limited?: boolean; memorial?: boolean; + hide_collections: boolean; } diff --git a/app/javascript/mastodon/features/followers/index.jsx b/app/javascript/mastodon/features/followers/index.jsx index e50b2171a0..4885f9ca99 100644 --- a/app/javascript/mastodon/features/followers/index.jsx +++ b/app/javascript/mastodon/features/followers/index.jsx @@ -45,6 +45,7 @@ const mapStateToProps = (state, { params: { acct, id } }) => { hasMore: !!state.getIn(['user_lists', 'followers', accountId, 'next']), isLoading: state.getIn(['user_lists', 'followers', accountId, 'isLoading'], true), suspended: state.getIn(['accounts', accountId, 'suspended'], false), + hideCollections: state.getIn(['accounts', accountId, 'hide_collections'], false), hidden: getAccountHidden(state, accountId), blockedBy: state.getIn(['relationships', accountId, 'blocked_by'], false), }; @@ -111,7 +112,7 @@ class Followers extends ImmutablePureComponent { }, 300, { leading: true }); render () { - const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl } = this.props; + const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl, hideCollections } = this.props; if (!isAccount) { return ( @@ -137,6 +138,8 @@ class Followers extends ImmutablePureComponent { emptyMessage = ; } else if (blockedBy) { emptyMessage = ; + } else if (hideCollections && accountIds.isEmpty()) { + emptyMessage = ; } else if (remote && accountIds.isEmpty()) { emptyMessage = ; } else { diff --git a/app/javascript/mastodon/features/following/index.jsx b/app/javascript/mastodon/features/following/index.jsx index 73e77aadd7..fb4a4d5c3a 100644 --- a/app/javascript/mastodon/features/following/index.jsx +++ b/app/javascript/mastodon/features/following/index.jsx @@ -45,6 +45,7 @@ const mapStateToProps = (state, { params: { acct, id } }) => { hasMore: !!state.getIn(['user_lists', 'following', accountId, 'next']), isLoading: state.getIn(['user_lists', 'following', accountId, 'isLoading'], true), suspended: state.getIn(['accounts', accountId, 'suspended'], false), + hideCollections: state.getIn(['accounts', accountId, 'hide_collections'], false), hidden: getAccountHidden(state, accountId), blockedBy: state.getIn(['relationships', accountId, 'blocked_by'], false), }; @@ -111,7 +112,7 @@ class Following extends ImmutablePureComponent { }, 300, { leading: true }); render () { - const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl } = this.props; + const { accountId, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, suspended, hidden, remote, remoteUrl, hideCollections } = this.props; if (!isAccount) { return ( @@ -137,6 +138,8 @@ class Following extends ImmutablePureComponent { emptyMessage = ; } else if (blockedBy) { emptyMessage = ; + } else if (hideCollections && accountIds.isEmpty()) { + emptyMessage = ; } else if (remote && accountIds.isEmpty()) { emptyMessage = ; } else { diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 4399b99951..9cbaf93054 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -222,6 +222,7 @@ "emoji_button.search_results": "Search results", "emoji_button.symbols": "Symbols", "emoji_button.travel": "Travel & Places", + "empty_column.account_hides_collections": "This user has chosen to not make this information available", "empty_column.account_suspended": "Account suspended", "empty_column.account_timeline": "No posts here!", "empty_column.account_unavailable": "Profile unavailable", diff --git a/app/javascript/mastodon/models/account.ts b/app/javascript/mastodon/models/account.ts index f20d2a2d3e..00066e2840 100644 --- a/app/javascript/mastodon/models/account.ts +++ b/app/javascript/mastodon/models/account.ts @@ -93,6 +93,7 @@ export const accountDefaultValues: AccountShape = { memorial: false, limited: false, moved: null, + hide_collections: false, }; const AccountFactory = ImmutableRecord(accountDefaultValues); diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 435ae36b74..8c6520b303 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -8,7 +8,7 @@ class REST::AccountSerializer < ActiveModel::Serializer attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at, :note, :url, :uri, :avatar, :avatar_static, :header, :header_static, - :followers_count, :following_count, :statuses_count, :last_status_at + :followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?