From c013627081becd7882165876c072a28d413ddf37 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 6 Sep 2023 23:13:14 +0200 Subject: [PATCH] Remove profile directory --- .../api/v1/directories_controller.rb | 55 ------ .../mastodon/features/directory/index.jsx | 183 ------------------ .../components/account_card.jsx | 0 .../mastodon/features/explore/suggestions.jsx | 3 +- .../features/ui/components/columns_area.jsx | 2 - .../features/ui/components/link_footer.jsx | 9 +- app/javascript/mastodon/features/ui/index.jsx | 2 - .../features/ui/util/async-components.js | 4 - app/javascript/mastodon/initial_state.js | 2 - app/models/form/admin_settings.rb | 2 - app/serializers/initial_state_serializer.rb | 1 - .../admin/settings/discovery/show.html.haml | 5 - config/routes.rb | 1 - config/routes/api.rb | 2 - 14 files changed, 3 insertions(+), 268 deletions(-) delete mode 100644 app/controllers/api/v1/directories_controller.rb delete mode 100644 app/javascript/mastodon/features/directory/index.jsx rename app/javascript/mastodon/features/{directory => explore}/components/account_card.jsx (100%) diff --git a/app/controllers/api/v1/directories_controller.rb b/app/controllers/api/v1/directories_controller.rb deleted file mode 100644 index 1109435507..0000000000 --- a/app/controllers/api/v1/directories_controller.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -class Api::V1::DirectoriesController < Api::BaseController - before_action :require_enabled! - before_action :set_accounts - - def show - cache_if_unauthenticated! - render json: @accounts, each_serializer: REST::AccountSerializer - end - - private - - def require_enabled! - return not_found unless Setting.profile_directory - end - - def set_accounts - @accounts = accounts_scope.offset(params[:offset]).limit(limit_param(DEFAULT_ACCOUNTS_LIMIT)) - end - - def accounts_scope - Account.discoverable.tap do |scope| - scope.merge!(account_order_scope) - scope.merge!(local_account_scope) if local_accounts? - scope.merge!(account_exclusion_scope) if current_account - scope.merge!(account_domain_block_scope) if current_account && !local_accounts? - end - end - - def local_accounts? - truthy_param?(:local) - end - - def account_order_scope - case params[:order] - when 'new' - Account.order(id: :desc) - when 'active', nil - Account.by_recent_status - end - end - - def local_account_scope - Account.local - end - - def account_exclusion_scope - Account.not_excluded_by_account(current_account) - end - - def account_domain_block_scope - Account.not_domain_blocked_by_account(current_account) - end -end diff --git a/app/javascript/mastodon/features/directory/index.jsx b/app/javascript/mastodon/features/directory/index.jsx deleted file mode 100644 index df25331966..0000000000 --- a/app/javascript/mastodon/features/directory/index.jsx +++ /dev/null @@ -1,183 +0,0 @@ -import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; - -import { defineMessages, injectIntl } from 'react-intl'; - -import { Helmet } from 'react-helmet'; - -import { List as ImmutableList } from 'immutable'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import { connect } from 'react-redux'; - -import { addColumn, removeColumn, moveColumn, changeColumnParams } from 'mastodon/actions/columns'; -import { fetchDirectory, expandDirectory } from 'mastodon/actions/directory'; -import Column from 'mastodon/components/column'; -import ColumnHeader from 'mastodon/components/column_header'; -import { LoadMore } from 'mastodon/components/load_more'; -import { LoadingIndicator } from 'mastodon/components/loading_indicator'; -import { RadioButton } from 'mastodon/components/radio_button'; -import ScrollContainer from 'mastodon/containers/scroll_container'; - -import AccountCard from './components/account_card'; - -const messages = defineMessages({ - title: { id: 'column.directory', defaultMessage: 'Browse profiles' }, - recentlyActive: { id: 'directory.recently_active', defaultMessage: 'Recently active' }, - newArrivals: { id: 'directory.new_arrivals', defaultMessage: 'New arrivals' }, - local: { id: 'directory.local', defaultMessage: 'From {domain} only' }, - federated: { id: 'directory.federated', defaultMessage: 'From known fediverse' }, -}); - -const mapStateToProps = state => ({ - accountIds: state.getIn(['user_lists', 'directory', 'items'], ImmutableList()), - isLoading: state.getIn(['user_lists', 'directory', 'isLoading'], true), - domain: state.getIn(['meta', 'domain']), -}); - -class Directory extends PureComponent { - - static contextTypes = { - router: PropTypes.object, - }; - - static propTypes = { - isLoading: PropTypes.bool, - accountIds: ImmutablePropTypes.list.isRequired, - dispatch: PropTypes.func.isRequired, - columnId: PropTypes.string, - intl: PropTypes.object.isRequired, - multiColumn: PropTypes.bool, - domain: PropTypes.string.isRequired, - params: PropTypes.shape({ - order: PropTypes.string, - local: PropTypes.bool, - }), - }; - - state = { - order: null, - local: null, - }; - - handlePin = () => { - const { columnId, dispatch } = this.props; - - if (columnId) { - dispatch(removeColumn(columnId)); - } else { - dispatch(addColumn('DIRECTORY', this.getParams(this.props, this.state))); - } - }; - - getParams = (props, state) => ({ - order: state.order === null ? (props.params.order || 'active') : state.order, - local: state.local === null ? (props.params.local || false) : state.local, - }); - - handleMove = dir => { - const { columnId, dispatch } = this.props; - dispatch(moveColumn(columnId, dir)); - }; - - handleHeaderClick = () => { - this.column.scrollTop(); - }; - - componentDidMount () { - const { dispatch } = this.props; - dispatch(fetchDirectory(this.getParams(this.props, this.state))); - } - - componentDidUpdate (prevProps, prevState) { - const { dispatch } = this.props; - const paramsOld = this.getParams(prevProps, prevState); - const paramsNew = this.getParams(this.props, this.state); - - if (paramsOld.order !== paramsNew.order || paramsOld.local !== paramsNew.local) { - dispatch(fetchDirectory(paramsNew)); - } - } - - setRef = c => { - this.column = c; - }; - - handleChangeOrder = e => { - const { dispatch, columnId } = this.props; - - if (columnId) { - dispatch(changeColumnParams(columnId, ['order'], e.target.value)); - } else { - this.setState({ order: e.target.value }); - } - }; - - handleChangeLocal = e => { - const { dispatch, columnId } = this.props; - - if (columnId) { - dispatch(changeColumnParams(columnId, ['local'], e.target.value === '1')); - } else { - this.setState({ local: e.target.value === '1' }); - } - }; - - handleLoadMore = () => { - const { dispatch } = this.props; - dispatch(expandDirectory(this.getParams(this.props, this.state))); - }; - - render () { - const { isLoading, accountIds, intl, columnId, multiColumn, domain } = this.props; - const { order, local } = this.getParams(this.props, this.state); - const pinned = !!columnId; - - const scrollableArea = ( -
-
-
- - -
- -
- - -
-
- -
- {isLoading ? : accountIds.map(accountId => ( - - ))} -
- - -
- ); - - return ( - - - - {multiColumn && !pinned ? {scrollableArea} : scrollableArea} - - - {intl.formatMessage(messages.title)} - - - - ); - } - -} - -export default connect(mapStateToProps)(injectIntl(Directory)); diff --git a/app/javascript/mastodon/features/directory/components/account_card.jsx b/app/javascript/mastodon/features/explore/components/account_card.jsx similarity index 100% rename from app/javascript/mastodon/features/directory/components/account_card.jsx rename to app/javascript/mastodon/features/explore/components/account_card.jsx diff --git a/app/javascript/mastodon/features/explore/suggestions.jsx b/app/javascript/mastodon/features/explore/suggestions.jsx index f2907cdb22..15b53bb454 100644 --- a/app/javascript/mastodon/features/explore/suggestions.jsx +++ b/app/javascript/mastodon/features/explore/suggestions.jsx @@ -8,7 +8,8 @@ import { connect } from 'react-redux'; import { fetchSuggestions } from 'mastodon/actions/suggestions'; import { LoadingIndicator } from 'mastodon/components/loading_indicator'; -import AccountCard from 'mastodon/features/directory/components/account_card'; + +import AccountCard from './components/account_card'; const mapStateToProps = state => ({ suggestions: state.getIn(['suggestions', 'items']), diff --git a/app/javascript/mastodon/features/ui/components/columns_area.jsx b/app/javascript/mastodon/features/ui/components/columns_area.jsx index 672f28fb7d..5ce5bfa9fa 100644 --- a/app/javascript/mastodon/features/ui/components/columns_area.jsx +++ b/app/javascript/mastodon/features/ui/components/columns_area.jsx @@ -19,7 +19,6 @@ import { FavouritedStatuses, BookmarkedStatuses, ListTimeline, - Directory, } from '../util/async-components'; import BundleColumnError from './bundle_column_error'; @@ -40,7 +39,6 @@ const componentMap = { 'FAVOURITES': FavouritedStatuses, 'BOOKMARKS': BookmarkedStatuses, 'LIST': ListTimeline, - 'DIRECTORY': Directory, }; export default class ColumnsArea extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/features/ui/components/link_footer.jsx b/app/javascript/mastodon/features/ui/components/link_footer.jsx index 7aaa887ac6..251a88b639 100644 --- a/app/javascript/mastodon/features/ui/components/link_footer.jsx +++ b/app/javascript/mastodon/features/ui/components/link_footer.jsx @@ -8,7 +8,7 @@ import { Link } from 'react-router-dom'; import { connect } from 'react-redux'; import { openModal } from 'mastodon/actions/modal'; -import { domain, version, source_url, statusPageUrl, profile_directory as profileDirectory } from 'mastodon/initial_state'; +import { domain, version, source_url, statusPageUrl } from 'mastodon/initial_state'; import { PERMISSION_INVITE_USERS } from 'mastodon/permissions'; import { logOut } from 'mastodon/utils/log_out'; @@ -57,7 +57,6 @@ class LinkFooter extends PureComponent { const { multiColumn } = this.props; const canInvite = signedIn && ((permissions & PERMISSION_INVITE_USERS) === PERMISSION_INVITE_USERS); - const canProfileDirectory = profileDirectory; const DividingCircle = {' ยท '}; @@ -79,12 +78,6 @@ class LinkFooter extends PureComponent { )} - {canProfileDirectory && ( - <> - {DividingCircle} - - - )} {DividingCircle}

diff --git a/app/javascript/mastodon/features/ui/index.jsx b/app/javascript/mastodon/features/ui/index.jsx index 55ccde72f5..028fbe0094 100644 --- a/app/javascript/mastodon/features/ui/index.jsx +++ b/app/javascript/mastodon/features/ui/index.jsx @@ -57,7 +57,6 @@ import { Mutes, PinnedStatuses, Lists, - Directory, Explore, Onboarding, About, @@ -207,7 +206,6 @@ class SwitchingColumnsArea extends PureComponent { - diff --git a/app/javascript/mastodon/features/ui/util/async-components.js b/app/javascript/mastodon/features/ui/util/async-components.js index 7b968204be..e4a01e4d1a 100644 --- a/app/javascript/mastodon/features/ui/util/async-components.js +++ b/app/javascript/mastodon/features/ui/util/async-components.js @@ -150,10 +150,6 @@ export function Audio () { return import(/* webpackChunkName: "features/audio" */'../../audio'); } -export function Directory () { - return import(/* webpackChunkName: "features/directory" */'../../directory'); -} - export function Onboarding () { return import(/* webpackChunkName: "features/onboarding" */'../../onboarding'); } diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 11cd2a1673..06d909ee77 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -63,7 +63,6 @@ * @property {string=} me * @property {string=} moved_to_account_id * @property {string=} owner - * @property {boolean} profile_directory * @property {boolean} registrations_open * @property {boolean} reduce_motion * @property {string} repository @@ -124,7 +123,6 @@ export const mascot = getMeta('mascot'); export const me = getMeta('me'); export const movedToAccountId = getMeta('moved_to_account_id'); export const owner = getMeta('owner'); -export const profile_directory = getMeta('profile_directory'); export const reduceMotion = getMeta('reduce_motion'); export const registrationsOpen = getMeta('registrations_open'); export const repository = getMeta('repository'); diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 7be026d85f..15539a4cbc 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -21,7 +21,6 @@ class Form::AdminSettings peers_api_enabled preview_sensitive_media custom_css - profile_directory thumbnail mascot trends @@ -50,7 +49,6 @@ class Form::AdminSettings activity_api_enabled peers_api_enabled preview_sensitive_media - profile_directory trends trends_as_landing_page trendable_by_default diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 56d45c588e..1d60cf86d2 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -26,7 +26,6 @@ class InitialStateSerializer < ActiveModel::Serializer version: instance_presenter.version, limited_federation_mode: Rails.configuration.x.limited_federation_mode, mascot: instance_presenter.mascot&.file&.url, - profile_directory: Setting.profile_directory, trends_enabled: Setting.trends, registrations_open: Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode, timeline_preview: Setting.timeline_preview, diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index 62011d5c56..c8f4a8e878 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -49,10 +49,5 @@ .fields-group = f.input :bootstrap_timeline_accounts, wrapper: :with_block_label - %h4= t('admin.settings.discovery.profile_directory') - - .fields-group - = f.input :profile_directory, as: :boolean, wrapper: :with_label - .actions = f.button :button, t('generic.save_changes'), type: :submit diff --git a/config/routes.rb b/config/routes.rb index 5de8562a8c..9a7377bdf3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,6 @@ Rails.application.routes.draw do /bookmarks /pinned /start - /directory /explore/(*any) /search /publish diff --git a/config/routes/api.rb b/config/routes/api.rb index 66eb82f59a..bb1fcaffc8 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -135,8 +135,6 @@ namespace :api, format: false do resource :domain_blocks, only: [:show, :create, :destroy] - resource :directory, only: [:show] - resources :follow_requests, only: [:index] do member do post :authorize