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