Fix error in logged-out hashtag view when remote posts require log-in (#36467)
This commit is contained in:
@@ -16,15 +16,21 @@ import { expandHashtagTimeline, clearTimeline } from 'mastodon/actions/timelines
|
||||
import Column from 'mastodon/components/column';
|
||||
import ColumnHeader from 'mastodon/components/column_header';
|
||||
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
|
||||
import { remoteTopicFeedAccess, me } from 'mastodon/initial_state';
|
||||
|
||||
import StatusListContainer from '../ui/containers/status_list_container';
|
||||
|
||||
import { HashtagHeader } from './components/hashtag_header';
|
||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
hasUnread: state.getIn(['timelines', `hashtag:${props.params.id}${props.params.local ? ':local' : ''}`, 'unread']) > 0,
|
||||
});
|
||||
const mapStateToProps = (state, props) => {
|
||||
const local = props.params.local || (!me && remoteTopicFeedAccess !== 'public');
|
||||
|
||||
return ({
|
||||
local,
|
||||
hasUnread: state.getIn(['timelines', `hashtag:${props.params.id}${local ? ':local' : ''}`, 'unread']) > 0,
|
||||
});
|
||||
};
|
||||
|
||||
class HashtagTimeline extends PureComponent {
|
||||
disconnects = [];
|
||||
@@ -113,16 +119,16 @@ class HashtagTimeline extends PureComponent {
|
||||
}
|
||||
|
||||
_unload () {
|
||||
const { dispatch } = this.props;
|
||||
const { id, local } = this.props.params;
|
||||
const { dispatch, local } = this.props;
|
||||
const { id } = this.props.params;
|
||||
|
||||
this._unsubscribe();
|
||||
dispatch(clearTimeline(`hashtag:${id}${local ? ':local' : ''}`));
|
||||
}
|
||||
|
||||
_load() {
|
||||
const { dispatch } = this.props;
|
||||
const { id, tags, local } = this.props.params;
|
||||
const { dispatch, local } = this.props;
|
||||
const { id, tags } = this.props.params;
|
||||
|
||||
this._subscribe(dispatch, id, tags, local);
|
||||
dispatch(expandHashtagTimeline(id, { tags, local }));
|
||||
@@ -133,8 +139,8 @@ class HashtagTimeline extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
const { params } = this.props;
|
||||
const { id, tags, local } = prevProps.params;
|
||||
const { params, local } = this.props;
|
||||
const { id, tags } = prevProps.params;
|
||||
|
||||
if (id !== params.id || !isEqual(tags, params.tags) || !isEqual(local, params.local)) {
|
||||
this._unload();
|
||||
@@ -151,15 +157,15 @@ class HashtagTimeline extends PureComponent {
|
||||
};
|
||||
|
||||
handleLoadMore = maxId => {
|
||||
const { dispatch, params } = this.props;
|
||||
const { id, tags, local } = params;
|
||||
const { dispatch, params, local } = this.props;
|
||||
const { id, tags } = params;
|
||||
|
||||
dispatch(expandHashtagTimeline(id, { maxId, tags, local }));
|
||||
};
|
||||
|
||||
render () {
|
||||
const { hasUnread, columnId, multiColumn } = this.props;
|
||||
const { id, local } = this.props.params;
|
||||
const { hasUnread, columnId, multiColumn, local } = this.props;
|
||||
const { id } = this.props.params;
|
||||
const pinned = !!columnId;
|
||||
|
||||
return (
|
||||
|
||||
@@ -34,6 +34,8 @@ interface InitialStateMeta {
|
||||
streaming_api_base_url: string;
|
||||
local_live_feed_access: 'public' | 'authenticated';
|
||||
remote_live_feed_access: 'public' | 'authenticated';
|
||||
local_topic_feed_access: 'public' | 'authenticated';
|
||||
remote_topic_feed_access: 'public' | 'authenticated';
|
||||
title: string;
|
||||
show_trends: boolean;
|
||||
trends_as_landing_page: boolean;
|
||||
@@ -113,6 +115,8 @@ export const singleUserMode = getMeta('single_user_mode');
|
||||
export const source_url = getMeta('source_url');
|
||||
export const localLiveFeedAccess = getMeta('local_live_feed_access');
|
||||
export const remoteLiveFeedAccess = getMeta('remote_live_feed_access');
|
||||
export const localTopicFeedAccess = getMeta('local_topic_feed_access');
|
||||
export const remoteTopicFeedAccess = getMeta('remote_topic_feed_access');
|
||||
export const title = getMeta('title');
|
||||
export const trendsAsLanding = getMeta('trends_as_landing_page');
|
||||
export const useBlurhash = getMeta('use_blurhash');
|
||||
|
||||
@@ -118,6 +118,8 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||
terms_of_service_enabled: TermsOfService.current.present?,
|
||||
local_live_feed_access: Setting.local_live_feed_access,
|
||||
remote_live_feed_access: Setting.remote_live_feed_access,
|
||||
local_topic_feed_access: Setting.local_topic_feed_access,
|
||||
remote_topic_feed_access: Setting.remote_topic_feed_access,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user