Add feature hide preview card

This commit is contained in:
noellabo 2023-02-12 18:57:28 +09:00
parent 53db1fcf24
commit b38f375d99
14 changed files with 73 additions and 3 deletions

View file

@ -119,6 +119,9 @@ class Settings::PreferencesController < Settings::BaseController
:setting_hide_personal_from_timeline,
:setting_hide_personal_from_account,
:setting_hide_privacy_meta,
:setting_hide_link_preview,
:setting_hide_photo_preview,
:setting_hide_video_preview,
setting_prohibited_visibilities: [],
notification_emails: %i(follow follow_request reblog favourite emoji_reaction status_reference mention digest report pending_account trending_tag),
interactions: %i(must_be_follower must_be_following must_be_following_dm must_be_dm_to_send_email must_be_following_reference)

View file

@ -20,7 +20,7 @@ import classNames from 'classnames';
import Icon from 'mastodon/components/icon';
import EmojiReactionsBar from 'mastodon/components/emoji_reactions_bar';
import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder';
import { displayMedia, enableReaction, compactReaction, show_reply_tree_button, enableStatusReference, disableRelativeTime } from 'mastodon/initial_state';
import { displayMedia, enableReaction, compactReaction, show_reply_tree_button, enableStatusReference, disableRelativeTime, hideLinkPreview, hidePhotoPreview, hideVideoPreview } from 'mastodon/initial_state';
import { List as ImmutableList } from 'immutable';
// We use the component (and not the container) since we do not want
@ -79,6 +79,19 @@ export const defaultMediaVisibility = (status) => {
return (displayMedia !== 'hide_all' && !status.get('sensitive') || displayMedia === 'show_all');
};
export const isHideCard = (type) => {
switch(type) {
case 'link':
return hideLinkPreview;
case 'photo':
return hidePhotoPreview;
case 'video':
return hideVideoPreview;
default:
return false;
}
};
const messages = defineMessages({
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
@ -554,7 +567,7 @@ class Status extends ImmutablePureComponent {
</Bundle>
);
}
} else if (showCard && status.get('spoiler_text').length === 0 && status.get('card')) {
} else if (showCard && status.get('spoiler_text').length === 0 && status.get('card') && !isHideCard(status.getIn(['card', 'type']))) {
media = (
<Card
onOpenMedia={this.handleOpenMedia}

View file

@ -5,6 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import Avatar from '../../../components/avatar';
import DisplayName from '../../../components/display_name';
import StatusContent from '../../../components/status_content';
import { isHideCard } from '../../../components/status';
import MediaGallery from '../../../components/media_gallery';
import { Link } from 'react-router-dom';
import { injectIntl, defineMessages, FormattedDate, FormattedMessage } from 'react-intl';
@ -342,7 +343,7 @@ class DetailedStatus extends ImmutablePureComponent {
/>
);
}
} else if (status.get('spoiler_text').length === 0) {
} else if (status.get('spoiler_text').length === 0 && !isHideCard(status.getIn(['card', 'type']))) {
media = <Card sensitive={status.get('sensitive')} onOpenMedia={this.props.onOpenMedia} card={status.get('card', null)} />;
}

View file

@ -72,6 +72,9 @@ export const hideDirectFromTimeline = getMeta('hide_direct_from_timeline');
export const hidePersonalFromTimeline = getMeta('hide_personal_from_timeline');
export const hidePersonalFromAccount = getMeta('hide_personal_from_account');
export const hidePrivacyMeta = getMeta('hide_privacy_meta');
export const hideLinkPreview = getMeta('hide_link_preview');
export const hidePhotoPreview = getMeta('hide_photo_preview');
export const hideVideoPreview = getMeta('hide_video_preview');
export const maxChars = initialState?.max_toot_chars ?? 500;

View file

@ -96,6 +96,9 @@ class UserSettingsDecorator
hide_personal_from_timeline
hide_personal_from_account
hide_privacy_meta
hide_link_preview
hide_photo_preview
hide_video_preview
).freeze
STRING_KEYS = %w(

View file

@ -146,6 +146,7 @@ class User < ApplicationRecord
:disable_post, :disable_reactions, :disable_follow, :disable_unfollow, :disable_block, :disable_domain_block, :disable_clear_all_notifications, :disable_account_delete,
:prohibited_visibilities, :prohibited_words,
:disable_relative_time, :hide_direct_from_timeline, :hide_personal_from_timeline, :hide_personal_from_account, :hide_privacy_meta,
:hide_link_preview, :hide_photo_preview, :hide_video_preview,
to: :settings, prefix: :setting, allow_nil: false

View file

@ -93,6 +93,9 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:hide_personal_from_timeline] = object.current_account.user.setting_hide_personal_from_timeline
store[:hide_personal_from_account] = object.current_account.user.setting_hide_personal_from_account
store[:hide_privacy_meta] = object.current_account.user.setting_hide_privacy_meta
store[:hide_link_preview] = object.current_account.user.setting_hide_link_preview
store[:hide_photo_preview] = object.current_account.user.setting_hide_photo_preview
store[:hide_video_preview] = object.current_account.user.setting_hide_video_preview
else
store[:auto_play_gif] = Setting.auto_play_gif
store[:display_media] = Setting.display_media

View file

@ -43,6 +43,21 @@ class REST::StatusSerializer < ActiveModel::Serializer
delegate :quote?, to: :object
def preview_card
object.preview_card unless hide_preview_card?
end
def hide_preview_card?
case object&.preview_card&.type
when 'link'
current_user&.setting_hide_link_preview
when 'photo'
current_user&.setting_hide_photo_preview
when 'video'
current_user&.setting_hide_video_preview
end
end
def id
object.id.to_s
end

View file

@ -99,5 +99,16 @@
.fields-group
= f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label
%h4= t 'appearance.preview_card'
.fields-group
= f.input :setting_hide_link_preview, as: :boolean, wrapper: :with_label, fedibird_features: true
.fields-group
= f.input :setting_hide_photo_preview, as: :boolean, wrapper: :with_label, fedibird_features: true
.fields-group
= f.input :setting_hide_video_preview, as: :boolean, wrapper: :with_label, fedibird_features: true
.actions
= f.button :button, t('generic.save_changes'), type: :submit

View file

@ -792,6 +792,7 @@ en:
body: Mastodon is translated by volunteers.
guide_link: https://crowdin.com/project/mastodon
guide_link_text: Everyone can contribute.
preview_card: Preview Card
sensitive_content: Sensitive content
themes: Themes
toot_layout: Post layout

View file

@ -771,6 +771,7 @@ ja:
body: Mastodonは有志によって翻訳されています。
guide_link: https://ja.crowdin.com/project/mastodon
guide_link_text: 誰でも参加することができます。
preview_card: プレビューカード
sensitive_content: 閲覧注意コンテンツ
themes: テーマ
toot_layout: 投稿のレイアウト

View file

@ -96,11 +96,14 @@ en:
setting_hide_direct_from_timeline: Hide direct messages from the home and list timelines
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_link_preview: Hide the content preview card linked to the post
setting_hide_network: Who you follow and who follows you will be hidden on your profile
setting_hide_personal_from_account: Hide personal posts from the account post lists
setting_hide_personal_from_timeline: Hide personal posts from the home and list timelines
setting_hide_photo_preview: Hide the photo preview card linked to the post
setting_hide_privacy_meta: Hide the description from the drop-down menu for selecting visibility, showing only the name
setting_hide_statuses_count: The number of post will be hidden in your profile
setting_hide_video_preview: Hide the video preview card linked to the post
setting_match_visibility_of_references: If the referenced post is private, default the visibility of the post to private behavior accordingly
setting_new_features_policy: Set the acceptance policy when new features are added to Fedibird. The recommended setting will enable many new features, so set it to disabled if it is not desirable
setting_noindex: Affects your public profile and post pages
@ -290,11 +293,14 @@ en:
setting_hide_direct_from_timeline: Hide direct messages from the timeline
setting_hide_followers_count: Hide your followers count
setting_hide_following_count: Hide your following count
setting_hide_link_preview: Hide preview card (link)
setting_hide_network: Hide your social graph
setting_hide_personal_from_account: Hide personal posts from account posts
setting_hide_personal_from_timeline: Hide personal posts from the timeline
setting_hide_photo_preview: Hide preview card (photo)
setting_hide_privacy_meta: Hide visibility description
setting_hide_statuses_count: Hide your post count
setting_hide_video_preview: Hide preview card (video)
setting_info_font_size: Information header font size
setting_match_visibility_of_references: Match the visibility of the post to the references
setting_new_features_policy: Policy for new features

View file

@ -92,11 +92,14 @@ ja:
setting_hide_direct_from_timeline: ホームとリストタイムラインからダイレクトメッセージを隠します
setting_hide_followers_count: フォロワー数をプロフィールページで見られないようにします
setting_hide_following_count: フォロー数をプロフィールページで見られないようにします
setting_hide_link_preview: 投稿にリンクされたコンテンツのプレビューカードを隠します
setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします
setting_hide_personal_from_account: アカウントの投稿一覧から個人限定投稿を隠します
setting_hide_personal_from_timeline: ホームとリストタイムラインから個人限定投稿を隠します
setting_hide_photo_preview: 投稿にリンクされた画像のプレビューカードを隠します
setting_hide_privacy_meta: 公開範囲を選択するドロップダウンメニューから説明を隠し、名称のみ表示します
setting_hide_statuses_count: 投稿数をプロフィールページで見られないようにします
setting_hide_video_preview: 投稿にリンクされた動画のプレビューカードを隠します
setting_match_visibility_of_references: 参照先の投稿がフォロワー限定の場合、投稿の公開範囲をそれに合わせてフォロワー限定とする動作をデフォルトにします
setting_new_features_policy: Fedibirdに新しい機能が追加された時の受け入れポリシーを設定します。推奨設定は多くの新機能を有効にするので、望ましくない場合は無効に設定してください
setting_noindex: 公開プロフィールおよび各投稿ページに影響します
@ -286,11 +289,14 @@ ja:
setting_hide_direct_from_timeline: ダイレクトメッセージをタイムラインから隠す
setting_hide_followers_count: フォロワー数を隠す
setting_hide_following_count: フォロー数を隠す
setting_hide_link_preview: プレビューカード(リンク)を隠す
setting_hide_network: 繋がりを隠す
setting_hide_personal_from_account: 自分限定投稿をアカウントの投稿一覧から隠す
setting_hide_personal_from_timeline: 自分限定投稿をタイムラインから隠す
setting_hide_photo_preview: プレビューカード(画像)を隠す
setting_hide_privacy_meta: 公開範囲の説明を隠す
setting_hide_statuses_count: 投稿数を隠す
setting_hide_video_preview: プレビューカード(動画)を隠す
setting_info_font_size: 情報ヘッダのフォントサイズ
setting_match_visibility_of_references: 投稿の公開範囲を参照先に合わせる
setting_new_features_policy: 新機能へのポリシー

View file

@ -135,6 +135,9 @@ defaults: &defaults
hide_direct_from_timeline: false
hide_personal_from_timeline: false
hide_privacy_meta: false
hide_link_preview: false
hide_photo_preview: false
hide_video_preview: false
development:
<<: *defaults