Fix hashtag column not subscribing to stream on mount (#10040)

Fix #9895
pull/923/head
Eugen Rochko 2019-02-14 15:46:42 +01:00 committed by ThibG
parent d974988541
commit be9352266c
1 changed files with 12 additions and 5 deletions

View File

@ -40,15 +40,19 @@ export default class HashtagTimeline extends React.PureComponent {
title = () => { title = () => {
let title = [this.props.params.id]; let title = [this.props.params.id];
if (this.additionalFor('any')) { if (this.additionalFor('any')) {
title.push(' ', <FormattedMessage id='hashtag.column_header.tag_mode.any' values={{ additional: this.additionalFor('any') }} defaultMessage='or {additional}' />); title.push(' ', <FormattedMessage key='any' id='hashtag.column_header.tag_mode.any' values={{ additional: this.additionalFor('any') }} defaultMessage='or {additional}' />);
} }
if (this.additionalFor('all')) { if (this.additionalFor('all')) {
title.push(' ', <FormattedMessage id='hashtag.column_header.tag_mode.all' values={{ additional: this.additionalFor('all') }} defaultMessage='and {additional}' />); title.push(' ', <FormattedMessage key='all' id='hashtag.column_header.tag_mode.all' values={{ additional: this.additionalFor('all') }} defaultMessage='and {additional}' />);
} }
if (this.additionalFor('none')) { if (this.additionalFor('none')) {
title.push(' ', <FormattedMessage id='hashtag.column_header.tag_mode.none' values={{ additional: this.additionalFor('none') }} defaultMessage='without {additional}' />); title.push(' ', <FormattedMessage key='none' id='hashtag.column_header.tag_mode.none' values={{ additional: this.additionalFor('none') }} defaultMessage='without {additional}' />);
} }
return title; return title;
} }
@ -76,9 +80,10 @@ export default class HashtagTimeline extends React.PureComponent {
let all = (tags.all || []).map(tag => tag.value); let all = (tags.all || []).map(tag => tag.value);
let none = (tags.none || []).map(tag => tag.value); let none = (tags.none || []).map(tag => tag.value);
[id, ...any].map((tag) => { [id, ...any].map(tag => {
this.disconnects.push(dispatch(connectHashtagStream(id, tag, (status) => { this.disconnects.push(dispatch(connectHashtagStream(id, tag, status => {
let tags = status.tags.map(tag => tag.name); let tags = status.tags.map(tag => tag.name);
return all.filter(tag => tags.includes(tag)).length === all.length && return all.filter(tag => tags.includes(tag)).length === all.length &&
none.filter(tag => tags.includes(tag)).length === 0; none.filter(tag => tags.includes(tag)).length === 0;
}))); })));
@ -94,12 +99,14 @@ export default class HashtagTimeline extends React.PureComponent {
const { dispatch } = this.props; const { dispatch } = this.props;
const { id, tags } = this.props.params; const { id, tags } = this.props.params;
this._subscribe(dispatch, id, tags);
dispatch(expandHashtagTimeline(id, { tags })); dispatch(expandHashtagTimeline(id, { tags }));
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {
const { dispatch, params } = this.props; const { dispatch, params } = this.props;
const { id, tags } = nextProps.params; const { id, tags } = nextProps.params;
if (id !== params.id || !isEqual(tags, params.tags)) { if (id !== params.id || !isEqual(tags, params.tags)) {
this._unsubscribe(); this._unsubscribe();
this._subscribe(dispatch, id, tags); this._subscribe(dispatch, id, tags);