From 7ceeb97f3d0b67bd51ab915ce285f935e25d8c36 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Sun, 19 Apr 2020 04:52:39 +0900 Subject: [PATCH] [Glitch] Add local only to hashtag timeline Port front-end changes from 2c7128c7f0ee3073acb9897cda88255982368193 to glitch-soc Signed-off-by: Thibaut Girka --- .../flavours/glitch/actions/timelines.js | 3 +-- .../glitch/containers/timeline_container.js | 2 +- .../components/column_settings.js | 7 +++++++ .../glitch/features/hashtag_timeline/index.js | 16 ++++++++-------- .../standalone/hashtag_timeline/index.js | 14 ++++++++++---- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js index 1bbdd6142b..d9c75e063f 100644 --- a/app/javascript/flavours/glitch/actions/timelines.js +++ b/app/javascript/flavours/glitch/actions/timelines.js @@ -128,8 +128,7 @@ export const expandAccountTimeline = (accountId, { maxId, withReplies } export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true }); export const expandAccountMediaTimeline = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true, limit: 40 }); export const expandListTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }, done); - -export const expandHashtagTimeline = (hashtag, { maxId, tags } = {}, done = noOp) => { +export const expandHashtagTimeline = (hashtag, { maxId, tags, local } = {}, done = noOp) => { return expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`, { max_id: maxId, any: parseTags(tags, 'any'), diff --git a/app/javascript/flavours/glitch/containers/timeline_container.js b/app/javascript/flavours/glitch/containers/timeline_container.js index 6ce5566645..b61dc8dd7d 100644 --- a/app/javascript/flavours/glitch/containers/timeline_container.js +++ b/app/javascript/flavours/glitch/containers/timeline_container.js @@ -38,7 +38,7 @@ export default class TimelineContainer extends React.PureComponent { let timeline; if (hashtag) { - timeline = ; + timeline = ; } else { timeline = ; } diff --git a/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js b/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js index 9c39b158a4..956f167340 100644 --- a/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js +++ b/app/javascript/flavours/glitch/features/hashtag_timeline/components/column_settings.js @@ -4,6 +4,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import Toggle from 'react-toggle'; import AsyncSelect from 'react-select/async'; +import SettingToggle from '../../notifications/components/setting_toggle'; const messages = defineMessages({ placeholder: { id: 'hashtag.column_settings.select.placeholder', defaultMessage: 'Enter hashtags…' }, @@ -87,6 +88,8 @@ class ColumnSettings extends React.PureComponent { }; render () { + const { settings, onChange } = this.props; + return (
@@ -106,6 +109,10 @@ class ColumnSettings extends React.PureComponent { {this.modeSelect('none')}
)} + +
+ } /> +
); } diff --git a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js index 16dd80c4fc..e94f365019 100644 --- a/app/javascript/flavours/glitch/features/hashtag_timeline/index.js +++ b/app/javascript/flavours/glitch/features/hashtag_timeline/index.js @@ -97,21 +97,21 @@ class HashtagTimeline extends React.PureComponent { componentDidMount () { const { dispatch } = this.props; - const { id, tags } = this.props.params; + const { id, tags, local } = this.props.params; this._subscribe(dispatch, id, tags); - dispatch(expandHashtagTimeline(id, { tags })); + dispatch(expandHashtagTimeline(id, { tags, local })); } componentWillReceiveProps (nextProps) { const { dispatch, params } = this.props; - const { id, tags } = nextProps.params; + const { id, tags, local } = nextProps.params; - if (id !== params.id || !isEqual(tags, params.tags)) { + if (id !== params.id || !isEqual(tags, params.tags) || !isEqual(local, params.local)) { this._unsubscribe(); this._subscribe(dispatch, id, tags); - this.props.dispatch(clearTimeline(`hashtag:${id}`)); - this.props.dispatch(expandHashtagTimeline(id, { tags })); + dispatch(clearTimeline(`hashtag:${id}`)); + dispatch(expandHashtagTimeline(id, { tags, local })); } } @@ -124,8 +124,8 @@ class HashtagTimeline extends React.PureComponent { } handleLoadMore = maxId => { - const { id, tags } = this.props.params; - this.props.dispatch(expandHashtagTimeline(id, { maxId, tags })); + const { id, tags, local } = this.props.params; + this.props.dispatch(expandHashtagTimeline(id, { maxId, tags, local })); } render () { diff --git a/app/javascript/flavours/glitch/features/standalone/hashtag_timeline/index.js b/app/javascript/flavours/glitch/features/standalone/hashtag_timeline/index.js index 4fbd504efe..629f5c2eaf 100644 --- a/app/javascript/flavours/glitch/features/standalone/hashtag_timeline/index.js +++ b/app/javascript/flavours/glitch/features/standalone/hashtag_timeline/index.js @@ -24,19 +24,25 @@ class HashtagTimeline extends React.PureComponent { isLoading: PropTypes.bool.isRequired, hasMore: PropTypes.bool.isRequired, hashtag: PropTypes.string.isRequired, + local: PropTypes.bool.isRequired, + }; + + static defaultProps = { + local: false, }; componentDidMount () { - const { dispatch, hashtag } = this.props; + const { dispatch, hashtag, local } = this.props; - dispatch(expandHashtagTimeline(hashtag)); + dispatch(expandHashtagTimeline(hashtag, { local })); } handleLoadMore = () => { - const maxId = this.props.statusIds.last(); + const { dispatch, hashtag, local, statusIds } = this.props; + const maxId = statusIds.last(); if (maxId) { - this.props.dispatch(expandHashtagTimeline(this.props.hashtag, { maxId })); + dispatch(expandHashtagTimeline(hashtag, { maxId, local })); } }