From 4eeda6772796bcd08b8c63ec2e1f3e68a95cbca4 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Tue, 22 May 2018 21:44:32 +0900 Subject: [PATCH] Hide section headline for timelines in production (#7590) * Hide section headline for timelines in production * comment out --- .../components/section_headline.js | 59 +++++++++++++++++++ .../features/community_timeline/index.js | 32 ++++------ .../features/public_timeline/index.js | 32 ++++------ 3 files changed, 85 insertions(+), 38 deletions(-) create mode 100644 app/javascript/mastodon/features/community_timeline/components/section_headline.js diff --git a/app/javascript/mastodon/features/community_timeline/components/section_headline.js b/app/javascript/mastodon/features/community_timeline/components/section_headline.js new file mode 100644 index 000000000..c7176d04b --- /dev/null +++ b/app/javascript/mastodon/features/community_timeline/components/section_headline.js @@ -0,0 +1,59 @@ +import PropTypes from 'prop-types'; +import React, { Component, Fragment } from 'react'; +import { FormattedMessage } from 'react-intl'; +import { NavLink } from 'react-router-dom'; + +export default class SectionHeadline extends Component { + + static propTypes = { + timelineId: PropTypes.string.isRequired, + to: PropTypes.string.isRequired, + pinned: PropTypes.bool.isRequired, + onlyMedia: PropTypes.bool.isRequired, + onClick: PropTypes.func, + }; + + shouldComponentUpdate (nextProps) { + return ( + this.props.onlyMedia !== nextProps.onlyMedia || + this.props.pinned !== nextProps.pinned || + this.props.to !== nextProps.to || + this.props.timelineId !== nextProps.timelineId + ); + } + + handleClick = e => { + const { onClick } = this.props; + + if (typeof onClick === 'function') { + e.preventDefault(); + + onClick.call(this, e); + } + } + + render () { + const { timelineId, to, pinned, onlyMedia } = this.props; + + return ( +
+ {pinned ? ( + + + + + + + + + ) : ( + + + + + )} +
+ ); + } + +} diff --git a/app/javascript/mastodon/features/community_timeline/index.js b/app/javascript/mastodon/features/community_timeline/index.js index bae856c4b..58b8a8b73 100644 --- a/app/javascript/mastodon/features/community_timeline/index.js +++ b/app/javascript/mastodon/features/community_timeline/index.js @@ -1,7 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; -import { NavLink } from 'react-router-dom'; import PropTypes from 'prop-types'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; @@ -9,6 +8,7 @@ import ColumnHeader from '../../components/column_header'; import { expandCommunityTimeline } from '../../actions/timelines'; import { addColumn, removeColumn, moveColumn, changeColumnParams } from '../../actions/columns'; import ColumnSettingsContainer from './containers/column_settings_container'; +// import SectionHeadline from './components/section_headline'; import { connectCommunityStream } from '../../actions/streaming'; const messages = defineMessages({ @@ -90,8 +90,6 @@ export default class CommunityTimeline extends React.PureComponent { } handleHeadlineLinkClick = e => { - e.preventDefault(); - const { columnId, dispatch } = this.props; const onlyMedia = /\/media$/.test(e.currentTarget.href); @@ -102,21 +100,17 @@ export default class CommunityTimeline extends React.PureComponent { const { intl, hasUnread, columnId, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = pinned ? ( -
- - - - - - -
- ) : ( -
- - -
- ); + // pending + // + // const headline = ( + // + // ); return ( @@ -134,7 +128,7 @@ export default class CommunityTimeline extends React.PureComponent { { - e.preventDefault(); - const { columnId, dispatch } = this.props; const onlyMedia = /\/media$/.test(e.currentTarget.href); @@ -102,21 +100,17 @@ export default class PublicTimeline extends React.PureComponent { const { intl, columnId, hasUnread, multiColumn, onlyMedia } = this.props; const pinned = !!columnId; - const headline = pinned ? ( -
- - - - - - -
- ) : ( -
- - -
- ); + // pending + // + // const headline = ( + // + // ); return ( @@ -134,7 +128,7 @@ export default class PublicTimeline extends React.PureComponent {