From cd252a60620feda790b92ecdb83eb05fd3859a8b Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 12 Sep 2023 13:12:07 +0900 Subject: [PATCH] Add hiding emoji reaction setting --- app/javascript/mastodon/components/status.jsx | 4 ++-- .../mastodon/components/status_action_bar.jsx | 5 +++-- .../features/status/components/action_bar.jsx | 19 +++++++++++++------ .../status/components/detailed_status.jsx | 3 ++- app/javascript/mastodon/initial_state.js | 2 ++ app/models/concerns/has_user_settings.rb | 4 ++++ app/models/user_settings.rb | 1 + app/serializers/initial_state_serializer.rb | 1 + app/services/emoji_react_service.rb | 6 ++++-- .../preferences/appearance/show.html.haml | 1 + app/workers/delivery_emoji_reaction_worker.rb | 2 +- config/locales/simple_form.en.yml | 2 ++ config/locales/simple_form.ja.yml | 2 ++ 13 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 34b2445bbc..a5e8933995 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -18,7 +18,7 @@ import Card from '../features/status/components/card'; // to use the progress bar to show download progress import Bundle from '../features/ui/components/bundle'; import { MediaGallery, Video, Audio } from '../features/ui/util/async-components'; -import { displayMedia } from '../initial_state'; +import { displayMedia, enableEmojiReaction } from '../initial_state'; import { Avatar } from './avatar'; import { AvatarOverlay } from './avatar_overlay'; @@ -577,7 +577,7 @@ class Status extends ImmutablePureComponent { let emojiReactionsBar = null; if (!this.props.withoutEmojiReactions && status.get('emoji_reactions')) { const emojiReactions = status.get('emoji_reactions'); - if (emojiReactions.size > 0) { + if (emojiReactions.size > 0 && enableEmojiReaction) { emojiReactionsBar = ; } } diff --git a/app/javascript/mastodon/components/status_action_bar.jsx b/app/javascript/mastodon/components/status_action_bar.jsx index 84716d9614..79169e909f 100644 --- a/app/javascript/mastodon/components/status_action_bar.jsx +++ b/app/javascript/mastodon/components/status_action_bar.jsx @@ -10,9 +10,10 @@ import { connect } from 'react-redux'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions'; + import DropdownMenuContainer from '../containers/dropdown_menu_container'; import EmojiPickerDropdown from '../features/compose/containers/emoji_picker_dropdown_container'; -import { bookmarkCategoryNeeded, me } from '../initial_state'; +import { enableEmojiReaction , bookmarkCategoryNeeded, me } from '../initial_state'; import { IconButton } from './icon_button'; @@ -415,7 +416,7 @@ class StatusActionBar extends ImmutablePureComponent { const emojiPickerButton = ( ); - const emojiPickerDropdown = (writtenByMe || ((denyFromAll) && (following) && (followed))) && ( + const emojiPickerDropdown = enableEmojiReaction && (writtenByMe || ((denyFromAll) && (following) && (followed))) && ( ); diff --git a/app/javascript/mastodon/features/status/components/action_bar.jsx b/app/javascript/mastodon/features/status/components/action_bar.jsx index 3047d1e1c8..4d0cda9ed3 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.jsx +++ b/app/javascript/mastodon/features/status/components/action_bar.jsx @@ -10,9 +10,10 @@ import { connect } from 'react-redux'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions'; + import { IconButton } from '../../../components/icon_button'; import DropdownMenuContainer from '../../../containers/dropdown_menu_container'; -import { bookmarkCategoryNeeded, me } from '../../../initial_state'; +import { enableEmojiReaction , bookmarkCategoryNeeded, me } from '../../../initial_state'; import EmojiPickerDropdown from '../../compose/containers/emoji_picker_dropdown_container'; const messages = defineMessages({ @@ -305,10 +306,6 @@ class ActionBar extends PureComponent { } } - const emojiPickerButton = ( - - ); - let replyIcon; if (status.get('in_reply_to_id', null) === null) { replyIcon = 'reply'; @@ -329,13 +326,23 @@ class ActionBar extends PureComponent { reblogTitle = intl.formatMessage(messages.cannot_reblog); } + const following = !account.getIn(['other_settings', 'emoji_reaction_must_follower']) || (relationship && relationship.get('following')); + const followed = !account.getIn(['other_settings', 'emoji_reaction_must_following']) || (relationship && relationship.get('followed_by')); + const denyFromAll = !account.getIn(['other_settings', 'emoji_reaction_deny_from_all']); + const emojiPickerButton = ( + + ); + const emojiPickerDropdown = enableEmojiReaction && (writtenByMe || ((denyFromAll) && (following) && (followed))) && ( +
+ ); + return (
-
+ {emojiPickerDropdown}
diff --git a/app/javascript/mastodon/features/status/components/detailed_status.jsx b/app/javascript/mastodon/features/status/components/detailed_status.jsx index d21f99e42d..37f6537072 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.jsx +++ b/app/javascript/mastodon/features/status/components/detailed_status.jsx @@ -13,6 +13,7 @@ import EditedTimestamp from 'mastodon/components/edited_timestamp'; import { getHashtagBarForStatus } from 'mastodon/components/hashtag_bar'; import { Icon } from 'mastodon/components/icon'; import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder'; +import { enableEmojiReaction } from 'mastodon/initial_state'; import { Avatar } from '../../../components/avatar'; import { DisplayName } from '../../../components/display_name'; @@ -240,7 +241,7 @@ class DetailedStatus extends ImmutablePureComponent { let emojiReactionsBar = null; if (status.get('emoji_reactions')) { const emojiReactions = status.get('emoji_reactions'); - if (emojiReactions.size > 0) { + if (emojiReactions.size > 0 && enableEmojiReaction) { emojiReactionsBar = ; } } diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 3e84866233..e560e1bbca 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -59,6 +59,7 @@ * @property {boolean} display_media_expand * @property {string} domain * @property {string} dtl_tag + * @property {boolean} enable_emoji_reaction * @property {boolean} enable_login_privacy * @property {boolean} enable_dtl_menu * @property {boolean=} expand_spoilers @@ -126,6 +127,7 @@ export const displayMedia = getMeta('display_media'); export const displayMediaExpand = getMeta('display_media_expand'); export const domain = getMeta('domain'); export const dtlTag = getMeta('dtl_tag'); +export const enableEmojiReaction = getMeta('enable_emoji_reaction'); export const enableLoginPrivacy = getMeta('enable_login_privacy'); export const enableDtlMenu = getMeta('enable_dtl_menu'); export const expandSpoilers = getMeta('expand_spoilers'); diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb index d4a8b36659..0d91a0e1e2 100644 --- a/app/models/concerns/has_user_settings.rb +++ b/app/models/concerns/has_user_settings.rb @@ -43,6 +43,10 @@ module HasUserSettings settings['web.hide_recent_emojis'] end + def setting_enable_emoji_reaction + settings['web.enable_emoji_reaction'] + end + def setting_default_sensitive settings['default_sensitive'] end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 28492c1394..df6af8f38b 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -54,6 +54,7 @@ class UserSettings setting :enable_login_privacy, default: false setting :enable_dtl_menu, default: false setting :hide_recent_emojis, default: false + setting :enable_emoji_reaction, default: true setting :reblog_modal, default: false setting :unfollow_modal, default: true setting :reduce_motion, default: false diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 45888d7572..de8192e277 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -48,6 +48,7 @@ class InitialStateSerializer < ActiveModel::Serializer store[:display_media] = object.current_account.user.setting_display_media store[:display_media_expand] = object.current_account.user.setting_display_media_expand store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers + store[:enable_emoji_reaction] = object.current_account.user.setting_enable_emoji_reaction store[:enable_login_privacy] = object.current_account.user.setting_enable_login_privacy store[:enable_dtl_menu] = object.current_account.user.setting_enable_dtl_menu store[:hide_recent_emojis] = object.current_account.user.setting_hide_recent_emojis diff --git a/app/services/emoji_react_service.rb b/app/services/emoji_react_service.rb index 0daa7fd3df..0dfefa6f0b 100644 --- a/app/services/emoji_react_service.rb +++ b/app/services/emoji_react_service.rb @@ -46,8 +46,10 @@ class EmojiReactService < BaseService status = emoji_reaction.status if status.account.local? - LocalNotificationWorker.perform_async(status.account_id, emoji_reaction.id, 'EmojiReaction', 'reaction') if status.account.user&.setting_emoji_reaction_streaming_notify_impl2 - LocalNotificationWorker.perform_async(status.account_id, emoji_reaction.id, 'EmojiReaction', 'emoji_reaction') + if status.account.user&.setting_enable_emoji_reaction + LocalNotificationWorker.perform_async(status.account_id, emoji_reaction.id, 'EmojiReaction', 'reaction') if status.account.user&.setting_emoji_reaction_streaming_notify_impl2 + LocalNotificationWorker.perform_async(status.account_id, emoji_reaction.id, 'EmojiReaction', 'emoji_reaction') + end elsif status.account.activitypub? ActivityPub::DeliveryWorker.perform_async(build_json(emoji_reaction), emoji_reaction.account_id, status.account.inbox_url) end diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index c01d9a8311..71313c5232 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -39,6 +39,7 @@ .fields-group = ff.input :'web.hide_recent_emojis', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_recent_emojis'), hint: false + = ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction') .fields-group = ff.input :'web.bookmark_category_needed', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_bookmark_category_needed'), hint: I18n.t('simple_form.hints.defaults.setting_bookmark_category_needed') diff --git a/app/workers/delivery_emoji_reaction_worker.rb b/app/workers/delivery_emoji_reaction_worker.rb index d25e5e844a..af67d43a4f 100644 --- a/app/workers/delivery_emoji_reaction_worker.rb +++ b/app/workers/delivery_emoji_reaction_worker.rb @@ -11,7 +11,7 @@ class DeliveryEmojiReactionWorker if status.present? scope_status(status).includes(:user).find_each do |account| - redis.publish("timeline:#{account.id}", payload_json) if (account.user.nil? || !account.user&.setting_stop_emoji_reaction_streaming) && redis.exists?("subscribed:timeline:#{account.id}") + redis.publish("timeline:#{account.id}", payload_json) if (account.user.nil? || (!account.user&.setting_stop_emoji_reaction_streaming && !account.user&.setting_enable_emoji_reaction)) && redis.exists?("subscribed:timeline:#{account.id}") end end diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index c58eabf733..5c4c861e8f 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -69,6 +69,7 @@ en: setting_dtl_force_subscribable: Your post can be detected local user's antenna to subscribe deep timeline setting_dtl_force_with_tag: "With using #%{tag} tag, your post settings will be changed forcibly" setting_dtl_menu: Show DTL menu on web + setting_enable_emoji_reaction: If turn off, other users still can react your posts setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed username: You can use letters, numbers, and underscores @@ -241,6 +242,7 @@ en: setting_dtl_force_subscribable: Ignore your dissubscribable setting when using the DTL tag setting_dtl_force_with_tag: Post with DTL tag setting_emoji_reaction_streaming_notify_impl2: Enable stamp notification compat with Nyastodon, Catstodon, glitch-soc + setting_enable_emoji_reaction: Show emoji reaction on your display setting_enable_login_privacy: Enable login visibility setting_expand_spoilers: Always expand posts marked with content warnings setting_hide_followers_count: Hide followers count diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 3261a44e66..0696062428 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -71,6 +71,7 @@ ja: setting_dtl_force_subscribable: 購読拒否設定に関係なく、ディープタイムラインに向けた投稿はアンテナに掲載されます。ディープタイムラインをアンテナ経由で閲覧している人にあなたの発言が届きます setting_dtl_force_with_tag: "ハッシュタグ #%{tag} をつけて投稿するとき、公開範囲と検索許可を強制的に置き換えるかを設定します" setting_emoji_reaction_streaming_notify_impl2: 当該サーバーの独自機能に対応したアプリを利用時に、スタンプ機能を利用できます。動作確認していないため(そもそもそのようなアプリ自体を確認できていないため)正しく動かない場合があります + setting_enable_emoji_reaction: この機能を無効にしても、他の人はあなたの投稿にスタンプをつけられます setting_hide_network: フォローとフォロワーの情報がプロフィールページで見られないようにします setting_link_preview: プレビュー生成を停止することは、センシティブなサイトへのリンクを頻繁に投稿する人にも有効かもしれません setting_noai: AI学習への利用を禁止するメタタグをプロフィールページに追加します。ただし実効性があるとは限りません @@ -252,6 +253,7 @@ ja: setting_dtl_menu: Webクライアントのメニューにディープタイムラインを追加する setting_enable_login_privacy: 公開範囲「ログインユーザーのみ」をWeb UIで選択可能にする setting_emoji_reaction_streaming_notify_impl2: Nyastodon, Catstodon, glitch-soc互換のスタンプ機能を有効にする + setting_enable_emoji_reaction: 自分の画面に絵文字リアクションを表示する setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する setting_hide_followers_count: フォロワー数を隠す setting_hide_following_count: フォロー数を隠す