Skip to content

Commit

Permalink
Add: #36 アカウント詳細画面の「フォローされています」を隠すオプション
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Mar 5, 2024
1 parent 82a8026 commit 9f934c3
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Icon } from 'mastodon/components/icon';
import { IconButton } from 'mastodon/components/icon_button';
import { ShortNumber } from 'mastodon/components/short_number';
import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container';
import { autoPlayGif, me, domain } from 'mastodon/initial_state';
import { autoPlayGif, me, domain, isShowItem } from 'mastodon/initial_state';
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';

Expand Down Expand Up @@ -89,9 +89,9 @@ const titleFromAccount = account => {
const messageForFollowButton = relationship => {
if(!relationship) return messages.follow;

if (relationship.get('following') && relationship.get('followed_by')) {
if (relationship.get('following') && relationship.get('followed_by') && isShowItem('relationships')) {
return messages.mutual;
} else if (!relationship.get('following') && relationship.get('followed_by')) {
} else if (!relationship.get('following') && relationship.get('followed_by') && isShowItem('relationships')) {
return messages.followBack;
} else if (relationship.get('following')) {
return messages.unfollow;
Expand Down
6 changes: 5 additions & 1 deletion app/javascript/mastodon/features/followers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { debounce } from 'lodash';

import { TimelineHint } from 'mastodon/components/timeline_hint';
import BundleColumnError from 'mastodon/features/ui/components/bundle_column_error';
import { isHideItem, me } from 'mastodon/initial_state';
import { normalizeForLookup } from 'mastodon/reducers/accounts_map';
import { getAccountHidden } from 'mastodon/selectors';

Expand Down Expand Up @@ -130,7 +131,8 @@ class Followers extends ImmutablePureComponent {

let emptyMessage;

const forceEmptyState = blockedBy || suspended || hidden;
const isHideRelationships = isHideItem('relationships') && accountId === me;
const forceEmptyState = blockedBy || suspended || hidden || isHideRelationships;

if (suspended) {
emptyMessage = <FormattedMessage id='empty_column.account_suspended' defaultMessage='Account suspended' />;
Expand All @@ -142,6 +144,8 @@ class Followers extends ImmutablePureComponent {
emptyMessage = <FormattedMessage id='empty_column.account_hides_collections' defaultMessage='This user has chosen to not make this information available' />;
} else if (remote && accountIds.isEmpty()) {
emptyMessage = <RemoteHint url={remoteUrl} />;
} else if (isHideRelationships) {
emptyMessage = <FormattedMessage id='account.followers.hidden_from_me' defaultMessage='This information is hidden by your setting.' />;
} else {
emptyMessage = <FormattedMessage id='account.followers.empty' defaultMessage='No one follows this user yet.' />;
}
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/features/following/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { debounce } from 'lodash';

import { TimelineHint } from 'mastodon/components/timeline_hint';
import BundleColumnError from 'mastodon/features/ui/components/bundle_column_error';
import { isHideItem, me } from 'mastodon/initial_state';
import { normalizeForLookup } from 'mastodon/reducers/accounts_map';
import { getAccountHidden } from 'mastodon/selectors';

Expand Down Expand Up @@ -131,16 +132,17 @@ class Following extends ImmutablePureComponent {
let emptyMessage;

const forceEmptyState = blockedBy || suspended || hidden;
const normalizedAccountIds = isHideItem('relationships') ? accountIds.filter((id) => id !== me) : accountIds;

if (suspended) {
emptyMessage = <FormattedMessage id='empty_column.account_suspended' defaultMessage='Account suspended' />;
} else if (hidden) {
emptyMessage = <LimitedAccountHint accountId={accountId} />;
} else if (blockedBy) {
emptyMessage = <FormattedMessage id='empty_column.account_unavailable' defaultMessage='Profile unavailable' />;
} else if (hideCollections && accountIds.isEmpty()) {
} else if (hideCollections && normalizedAccountIds.isEmpty()) {
emptyMessage = <FormattedMessage id='empty_column.account_hides_collections' defaultMessage='This user has chosen to not make this information available' />;
} else if (remote && accountIds.isEmpty()) {
} else if (remote && normalizedAccountIds.isEmpty()) {
emptyMessage = <RemoteHint url={remoteUrl} />;
} else {
emptyMessage = <FormattedMessage id='account.follows.empty' defaultMessage="This user doesn't follow anyone yet." />;
Expand All @@ -163,7 +165,7 @@ class Following extends ImmutablePureComponent {
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
>
{forceEmptyState ? [] : accountIds.map(id =>
{forceEmptyState ? [] : normalizedAccountIds.map(id =>
<AccountContainer key={id} id={id} withNote={false} />,
)}
</ScrollableList>
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@


/**
* @typedef { 'blocking_quote'
* @typedef {
* | 'blocking_quote'
* | 'emoji_reaction_on_timeline'
* | 'emoji_reaction_unavailable_server'
* | 'emoji_reaction_count'
* | 'favourite_menu'
* | 'quote_in_home'
* | 'quote_in_public'
* | 'recent_emojis'
* | 'relationships'
* } HideItemsDefinition
*/

Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/user/has_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def setting_hide_blocking_quote
settings['web.hide_blocking_quote']
end

def setting_show_relationships
settings['web.show_relationships']
end

def setting_allow_quote
settings['allow_quote']
end
Expand Down
1 change: 1 addition & 0 deletions app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class KeyError < Error; end
setting :simple_timeline_menu, default: false
setting :show_quote_in_home, default: true
setting :show_quote_in_public, default: false
setting :show_relationships, default: true
setting :hide_blocking_quote, default: true
setting :hide_emoji_reaction_unavailable_server, default: false
setting :hide_favourite_menu, default: false
Expand Down
1 change: 1 addition & 0 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def meta
object_account_user.setting_show_emoji_reaction_on_timeline ? nil : 'emoji_reaction_on_timeline',
object_account_user.setting_show_quote_in_home ? nil : 'quote_in_home',
object_account_user.setting_show_quote_in_public ? nil : 'quote_in_public',
object_account_user.setting_show_relationships ? nil : 'relationships',
].compact
else
store[:auto_play_gif] = Setting.auto_play_gif
Expand Down
1 change: 1 addition & 0 deletions app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

.fields-group
= ff.input :'web.trends', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_trends')
= ff.input :'web.show_relationships', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_relationships')

%h4= t 'appearance.confirmation_dialogs'

Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ en:
setting_show_emoji_reaction_on_timeline: Show all emoji reactions on timeline
setting_show_quote_in_home: Show quotes in home, list or antenna timelines
setting_show_quote_in_public: Show quotes in public timelines
setting_show_relationships: Show relationships on account page
setting_simple_timeline_menu: Reduce post menu on timeline
setting_single_ref_to_quote: Deliver single reference to other server as quote
setting_slip_local_emoji_reaction: Allow bypassing emoji reaction from local users
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ ja:
setting_lock_follow_from_bot: botからのフォローを承認制にする
setting_show_quote_in_home: ホーム・リスト・アンテナなどで引用を表示する
setting_show_quote_in_public: 公開タイムライン(ローカル・連合)で引用を表示する
setting_show_relationships: アカウント詳細ベージで、相手からのフォロー状況を表示する
setting_stay_privacy: 投稿時に公開範囲を保存する
setting_public_post_to_unlisted: サードパーティから公開範囲「公開」で投稿した場合、「ローカル公開」に変更する
setting_reduce_motion: アニメーションの動きを減らす
Expand Down

0 comments on commit 9f934c3

Please sign in to comment.