From 6968c6bf40e4c1d94799a9fe99a091cc0fc91888 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Apr 2022 23:35:40 -0500 Subject: [PATCH] Remove BirthdayReminders component --- app/soapbox/components/birthday_reminders.js | 161 ------------------- app/soapbox/features/notifications/index.js | 35 +--- 2 files changed, 3 insertions(+), 193 deletions(-) delete mode 100644 app/soapbox/components/birthday_reminders.js diff --git a/app/soapbox/components/birthday_reminders.js b/app/soapbox/components/birthday_reminders.js deleted file mode 100644 index aa50a2fec..000000000 --- a/app/soapbox/components/birthday_reminders.js +++ /dev/null @@ -1,161 +0,0 @@ - -import PropTypes from 'prop-types'; -import React from 'react'; -import { HotKeys } from 'react-hotkeys'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import ImmutablePureComponent from 'react-immutable-pure-component'; -import { injectIntl, FormattedMessage } from 'react-intl'; -import { connect } from 'react-redux'; -import { Link } from 'react-router-dom'; - -import { fetchBirthdayReminders } from 'soapbox/actions/accounts'; -import { openModal } from 'soapbox/actions/modals'; -import Icon from 'soapbox/components/icon'; -import { HStack, Text } from 'soapbox/components/ui'; -import { makeGetAccount } from 'soapbox/selectors'; - -const mapStateToProps = (state, props) => { - const me = state.get('me'); - const getAccount = makeGetAccount(); - - const birthdays = state.getIn(['user_lists', 'birthday_reminders', me]); - - if (birthdays?.size > 0) { - return { - birthdays, - account: getAccount(state, birthdays.first()), - }; - } - - return { - birthdays, - }; -}; - -export default @connect(mapStateToProps) -@injectIntl -class BirthdayReminders extends ImmutablePureComponent { - - static propTypes = { - birthdays: ImmutablePropTypes.orderedSet, - intl: PropTypes.object.isRequired, - dispatch: PropTypes.func.isRequired, - onMoveDown: PropTypes.func, - }; - - componentDidMount() { - const { dispatch } = this.props; - - const date = new Date(); - - const day = date.getDate(); - const month = date.getMonth() + 1; - - dispatch(fetchBirthdayReminders(month, day)); - } - - getHandlers() { - return { - open: this.handleOpenBirthdaysModal, - moveDown: this.props.onMoveDown, - }; - } - - handleOpenBirthdaysModal = () => { - const { dispatch } = this.props; - - dispatch(openModal('BIRTHDAYS')); - } - - renderMessage() { - const { birthdays, account } = this.props; - - const link = ( - - - - ); - - if (birthdays.size === 1) { - return ; - } - - return ( - - - - ), - }} - /> - ); - } - - renderMessageForScreenReader = () => { - const { intl, birthdays, account } = this.props; - - if (birthdays.size === 1) { - return intl.formatMessage({ id: 'notification.birthday', defaultMessage: '{name} has a birthday today' }, { name: account.get('display_name') }); - } - - return intl.formatMessage( - { - id: 'notification.birthday_plural', - defaultMessage: '{name} and {more} have birthday today', - }, - { - name: account.get('display_name'), - more: intl.formatMessage( - { - id: 'notification.birthday.more', - defaultMessage: '{count} more {count, plural, one {friend} other {friends}}', - }, - { count: birthdays.size - 1 }, - ), - }, - ); - } - - render() { - const { birthdays } = this.props; - - if (!birthdays || birthdays.size === 0) return null; - - return ( - -
-
- - - - - {this.renderMessage()} - - -
-
-
- ); - } - -} diff --git a/app/soapbox/features/notifications/index.js b/app/soapbox/features/notifications/index.js index 5f739e913..2ed33a9c5 100644 --- a/app/soapbox/features/notifications/index.js +++ b/app/soapbox/features/notifications/index.js @@ -9,10 +9,8 @@ import { Virtuoso } from 'react-virtuoso'; import { createSelector } from 'reselect'; import { getSettings } from 'soapbox/actions/settings'; -import BirthdayReminders from 'soapbox/components/birthday_reminders'; import PullToRefresh from 'soapbox/components/pull-to-refresh'; import PlaceholderNotification from 'soapbox/features/placeholder/components/placeholder_notification'; -import { getFeatures } from 'soapbox/utils/features'; import { expandNotifications, @@ -30,12 +28,6 @@ const messages = defineMessages({ queue: { id: 'notifications.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {notification} other {notifications}}' }, }); -const Header = ({ context }) => ( - context.showBirthdayReminders ? ( - - ) : null -); - const Footer = ({ context }) => ( context.hasMore ? ( @@ -71,10 +63,6 @@ const getNotifications = createSelector([ const mapStateToProps = state => { const settings = getSettings(state); - const instance = state.get('instance'); - const features = getFeatures(instance); - const showBirthdayReminders = settings.getIn(['notifications', 'birthdays', 'show']) && settings.getIn(['notifications', 'quickFilter', 'active']) === 'all' && features.birthdays; - const birthdays = showBirthdayReminders && state.getIn(['user_lists', 'birthday_reminders', state.get('me')]); return { showFilterBar: settings.getIn(['notifications', 'quickFilter', 'show']), @@ -83,8 +71,6 @@ const mapStateToProps = state => { isUnread: state.getIn(['notifications', 'unread']) > 0, hasMore: state.getIn(['notifications', 'hasMore']), totalQueuedNotificationsCount: state.getIn(['notifications', 'totalQueuedNotificationsCount'], 0), - showBirthdayReminders, - hasBirthdays: !!birthdays, }; }; @@ -102,8 +88,6 @@ class Notifications extends React.PureComponent { hasMore: PropTypes.bool, dequeueNotifications: PropTypes.func, totalQueuedNotificationsCount: PropTypes.number, - showBirthdayReminders: PropTypes.bool, - hasBirthdays: PropTypes.bool, }; componentWillUnmount() { @@ -140,25 +124,15 @@ class Notifications extends React.PureComponent { } handleMoveUp = id => { - const { hasBirthdays } = this.props; - - let elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1; - if (hasBirthdays) elementIndex++; + const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1; this._selectChild(elementIndex, true); } handleMoveDown = id => { - const { hasBirthdays } = this.props; - - let elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1; - if (hasBirthdays) elementIndex++; + const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1; this._selectChild(elementIndex, false); } - handleMoveBelowBirthdays = () => { - this._selectChild(1, false); - } - _selectChild(index, align_top) { const container = this.column; const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`); @@ -183,7 +157,7 @@ class Notifications extends React.PureComponent { } render() { - const { intl, notifications, isLoading, hasMore, showFilterBar, totalQueuedNotificationsCount, showBirthdayReminders } = this.props; + const { intl, notifications, isLoading, hasMore, showFilterBar, totalQueuedNotificationsCount } = this.props; const emptyMessage = ; const filterBarContainer = showFilterBar @@ -208,13 +182,10 @@ class Notifications extends React.PureComponent { )} context={{ hasMore, - showBirthdayReminders, - handleMoveBelowBirthdays: this.handleMoveBelowBirthdays, isLoading, emptyMessage, }} components={{ - Header, ScrollSeekPlaceholder: PlaceholderNotification, Footer, EmptyPlaceholder,