Skip to content

Commit

Permalink
Fix hashtag column not subscribing to stream on mount (mastodon#10040)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and ClearlyClaire committed Feb 18, 2019
1 parent d974988 commit be93522
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/javascript/flavours/glitch/features/hashtag_timeline/index.js
Expand Up @@ -40,15 +40,19 @@ export default class HashtagTimeline extends React.PureComponent {

title = () => {
let title = [this.props.params.id];

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')) {
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')) {
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;
}

Expand Down Expand Up @@ -76,9 +80,10 @@ export default class HashtagTimeline extends React.PureComponent {
let all = (tags.all || []).map(tag => tag.value);
let none = (tags.none || []).map(tag => tag.value);

[id, ...any].map((tag) => {
this.disconnects.push(dispatch(connectHashtagStream(id, tag, (status) => {
[id, ...any].map(tag => {
this.disconnects.push(dispatch(connectHashtagStream(id, tag, status => {
let tags = status.tags.map(tag => tag.name);

return all.filter(tag => tags.includes(tag)).length === all.length &&
none.filter(tag => tags.includes(tag)).length === 0;
})));
Expand All @@ -94,12 +99,14 @@ export default class HashtagTimeline extends React.PureComponent {
const { dispatch } = this.props;
const { id, tags } = this.props.params;

this._subscribe(dispatch, id, tags);
dispatch(expandHashtagTimeline(id, { tags }));
}

componentWillReceiveProps (nextProps) {
const { dispatch, params } = this.props;
const { id, tags } = nextProps.params;

if (id !== params.id || !isEqual(tags, params.tags)) {
this._unsubscribe();
this._subscribe(dispatch, id, tags);
Expand Down

0 comments on commit be93522

Please sign in to comment.