From 37ca59815cd3a3b2662e20f0c28185eb0d604dd4 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 22 Mar 2024 17:24:04 +0100 Subject: [PATCH] Remove setting for unfollow confirmation modal, and make it unconditional (#29373) --- .../mastodon/containers/account_container.jsx | 21 +++----- .../containers/header_container.jsx | 41 ++++++--------- .../directory/components/account_card.jsx | 52 ++++++++----------- app/javascript/mastodon/initial_state.js | 2 - app/models/concerns/user/has_settings.rb | 4 -- app/models/user_settings.rb | 1 - app/serializers/initial_state_serializer.rb | 1 - .../preferences/appearance/show.html.haml | 1 - 8 files changed, 46 insertions(+), 77 deletions(-) diff --git a/app/javascript/mastodon/containers/account_container.jsx b/app/javascript/mastodon/containers/account_container.jsx index a134452e7..f171fcc2f 100644 --- a/app/javascript/mastodon/containers/account_container.jsx +++ b/app/javascript/mastodon/containers/account_container.jsx @@ -13,7 +13,6 @@ import { import { openModal } from '../actions/modal'; import { initMuteModal } from '../actions/mutes'; import Account from '../components/account'; -import { unfollowModal } from '../initial_state'; import { makeGetAccount } from '../selectors'; const messages = defineMessages({ @@ -34,18 +33,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow (account) { if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) { - if (unfollowModal) { - dispatch(openModal({ - modalType: 'CONFIRM', - modalProps: { - message: @{account.get('acct')} }} />, - confirm: intl.formatMessage(messages.unfollowConfirm), - onConfirm: () => dispatch(unfollowAccount(account.get('id'))), - }, - })); - } else { - dispatch(unfollowAccount(account.get('id'))); - } + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: @{account.get('acct')} }} />, + confirm: intl.formatMessage(messages.unfollowConfirm), + onConfirm: () => dispatch(unfollowAccount(account.get('id'))), + }, + })); } else { dispatch(followAccount(account.get('id'))); } diff --git a/app/javascript/mastodon/features/account_timeline/containers/header_container.jsx b/app/javascript/mastodon/features/account_timeline/containers/header_container.jsx index 071dbdbfb..73fd62841 100644 --- a/app/javascript/mastodon/features/account_timeline/containers/header_container.jsx +++ b/app/javascript/mastodon/features/account_timeline/containers/header_container.jsx @@ -21,7 +21,6 @@ import { initDomainBlockModal, unblockDomain } from '../../../actions/domain_blo import { openModal } from '../../../actions/modal'; import { initMuteModal } from '../../../actions/mutes'; import { initReport } from '../../../actions/reports'; -import { unfollowModal } from '../../../initial_state'; import { makeGetAccount, getAccountHidden } from '../../../selectors'; import Header from '../components/header'; @@ -47,31 +46,23 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow (account) { if (account.getIn(['relationship', 'following'])) { - if (unfollowModal) { - dispatch(openModal({ - modalType: 'CONFIRM', - modalProps: { - message: @{account.get('acct')} }} />, - confirm: intl.formatMessage(messages.unfollowConfirm), - onConfirm: () => dispatch(unfollowAccount(account.get('id'))), - }, - })); - } else { - dispatch(unfollowAccount(account.get('id'))); - } + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: @{account.get('acct')} }} />, + confirm: intl.formatMessage(messages.unfollowConfirm), + onConfirm: () => dispatch(unfollowAccount(account.get('id'))), + }, + })); } else if (account.getIn(['relationship', 'requested'])) { - if (unfollowModal) { - dispatch(openModal({ - modalType: 'CONFIRM', - modalProps: { - message: @{account.get('acct')} }} />, - confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), - onConfirm: () => dispatch(unfollowAccount(account.get('id'))), - }, - })); - } else { - dispatch(unfollowAccount(account.get('id'))); - } + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: @{account.get('acct')} }} />, + confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), + onConfirm: () => dispatch(unfollowAccount(account.get('id'))), + }, + })); } else { dispatch(followAccount(account.get('id'))); } diff --git a/app/javascript/mastodon/features/directory/components/account_card.jsx b/app/javascript/mastodon/features/directory/components/account_card.jsx index ff1f8a653..9c5e68812 100644 --- a/app/javascript/mastodon/features/directory/components/account_card.jsx +++ b/app/javascript/mastodon/features/directory/components/account_card.jsx @@ -20,7 +20,7 @@ import { Avatar } from 'mastodon/components/avatar'; import { Button } from 'mastodon/components/button'; import { DisplayName } from 'mastodon/components/display_name'; import { ShortNumber } from 'mastodon/components/short_number'; -import { autoPlayGif, me, unfollowModal } from 'mastodon/initial_state'; +import { autoPlayGif, me } from 'mastodon/initial_state'; import { makeGetAccount } from 'mastodon/selectors'; const messages = defineMessages({ @@ -48,38 +48,30 @@ const makeMapStateToProps = () => { const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow(account) { if (account.getIn(['relationship', 'following'])) { - if (unfollowModal) { - dispatch( - openModal({ - modalType: 'CONFIRM', - modalProps: { - message: ( - @{account.get('acct')} }} - /> - ), - confirm: intl.formatMessage(messages.unfollowConfirm), - onConfirm: () => dispatch(unfollowAccount(account.get('id'))), - } }), - ); - } else { - dispatch(unfollowAccount(account.get('id'))); - } - } else if (account.getIn(['relationship', 'requested'])) { - if (unfollowModal) { - dispatch(openModal({ + dispatch( + openModal({ modalType: 'CONFIRM', modalProps: { - message: @{account.get('acct')} }} />, - confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), + message: ( + @{account.get('acct')} }} + /> + ), + confirm: intl.formatMessage(messages.unfollowConfirm), onConfirm: () => dispatch(unfollowAccount(account.get('id'))), - }, - })); - } else { - dispatch(unfollowAccount(account.get('id'))); - } + } }), + ); + } else if (account.getIn(['relationship', 'requested'])) { + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: @{account.get('acct')} }} />, + confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), + onConfirm: () => dispatch(unfollowAccount(account.get('id'))), + }, + })); } else { dispatch(followAccount(account.get('id'))); } diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 596c9ca49..d8c57a2a0 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -38,7 +38,6 @@ * @property {string} title * @property {boolean} show_trends * @property {boolean} trends_as_landing_page - * @property {boolean} unfollow_modal * @property {boolean} use_blurhash * @property {boolean=} use_pending_items * @property {string} version @@ -99,7 +98,6 @@ export const source_url = getMeta('source_url'); export const timelinePreview = getMeta('timeline_preview'); export const title = getMeta('title'); export const trendsAsLanding = getMeta('trends_as_landing_page'); -export const unfollowModal = getMeta('unfollow_modal'); export const useBlurhash = getMeta('use_blurhash'); export const usePendingItems = getMeta('use_pending_items'); export const version = getMeta('version'); diff --git a/app/models/concerns/user/has_settings.rb b/app/models/concerns/user/has_settings.rb index bfa8aa2ca..65373325f 100644 --- a/app/models/concerns/user/has_settings.rb +++ b/app/models/concerns/user/has_settings.rb @@ -27,10 +27,6 @@ module User::HasSettings settings['default_sensitive'] end - def setting_unfollow_modal - settings['web.unfollow_modal'] - end - def setting_boost_modal settings['web.reblog_modal'] end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 030cbec4d..6571632fc 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -27,7 +27,6 @@ class UserSettings setting :disable_swiping, default: false setting :delete_modal, default: true setting :reblog_modal, default: false - setting :unfollow_modal, default: true setting :reduce_motion, default: false setting :expand_content_warnings, default: false setting :display_media, default: 'default', in: %w(default show_all hide_all) diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 9f7921461..72aaabcfc 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -17,7 +17,6 @@ class InitialStateSerializer < ActiveModel::Serializer if object.current_account store[:me] = object.current_account.id.to_s - store[:unfollow_modal] = object_account_user.setting_unfollow_modal store[:boost_modal] = object_account_user.setting_boost_modal store[:delete_modal] = object_account_user.setting_delete_modal store[:auto_play_gif] = object_account_user.setting_auto_play_gif diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml index 76cd4381d..e89e015b2 100644 --- a/app/views/settings/preferences/appearance/show.html.haml +++ b/app/views/settings/preferences/appearance/show.html.haml @@ -66,7 +66,6 @@ %h4= t 'appearance.confirmation_dialogs' .fields-group - = ff.input :'web.unfollow_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_unfollow_modal') = ff.input :'web.reblog_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_boost_modal') = ff.input :'web.delete_modal', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_delete_modal')