forked from treehouse/mastodon
Fix regexp filtering in pinned community/public TLs (#1840)
parent
d4e63cd980
commit
2a46fcc3ed
|
@ -25,6 +25,7 @@ export default class StatusList extends ImmutablePureComponent {
|
|||
alwaysPrepend: PropTypes.bool,
|
||||
emptyMessage: PropTypes.node,
|
||||
timelineId: PropTypes.string.isRequired,
|
||||
regex: PropTypes.string,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
|
|
@ -19,11 +19,13 @@ const mapStateToProps = (state, { columnId }) => {
|
|||
const columns = state.getIn(['settings', 'columns']);
|
||||
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||
const onlyMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']);
|
||||
const regex = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'regex', 'body']) : state.getIn(['settings', 'community', 'regex', 'body']);
|
||||
const timelineState = state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`]);
|
||||
|
||||
return {
|
||||
hasUnread: !!timelineState && timelineState.get('unread') > 0,
|
||||
onlyMedia,
|
||||
regex,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -46,6 +48,7 @@ class CommunityTimeline extends React.PureComponent {
|
|||
hasUnread: PropTypes.bool,
|
||||
multiColumn: PropTypes.bool,
|
||||
onlyMedia: PropTypes.bool,
|
||||
regex: PropTypes.string,
|
||||
};
|
||||
|
||||
handlePin = () => {
|
||||
|
@ -127,6 +130,7 @@ class CommunityTimeline extends React.PureComponent {
|
|||
onLoadMore={this.handleLoadMore}
|
||||
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}
|
||||
bindToDocument={!multiColumn}
|
||||
regex={this.props.regex}
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
|
|
|
@ -26,6 +26,7 @@ const mapStateToProps = state => ({
|
|||
hasAnnouncements: !state.getIn(['announcements', 'items']).isEmpty(),
|
||||
unreadAnnouncements: state.getIn(['announcements', 'items']).count(item => !item.get('read')),
|
||||
showAnnouncements: state.getIn(['announcements', 'show']),
|
||||
regex: state.getIn(['settings', 'home', 'regex', 'body']),
|
||||
});
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
|
@ -42,6 +43,7 @@ class HomeTimeline extends React.PureComponent {
|
|||
hasAnnouncements: PropTypes.bool,
|
||||
unreadAnnouncements: PropTypes.number,
|
||||
showAnnouncements: PropTypes.bool,
|
||||
regex: PropTypes.string,
|
||||
};
|
||||
|
||||
handlePin = () => {
|
||||
|
@ -154,6 +156,7 @@ class HomeTimeline extends React.PureComponent {
|
|||
timelineId='home'
|
||||
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Follow more people to fill it up. {suggestions}' values={{ suggestions: <Link to='/start'><FormattedMessage id='empty_column.home.suggestions' defaultMessage='See some suggestions' /></Link> }} />}
|
||||
bindToDocument={!multiColumn}
|
||||
regex={this.props.regex}
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
|
|
|
@ -21,6 +21,7 @@ const mapStateToProps = (state, { columnId }) => {
|
|||
const onlyMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']);
|
||||
const onlyRemote = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyRemote']) : state.getIn(['settings', 'public', 'other', 'onlyRemote']);
|
||||
const allowLocalOnly = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'allowLocalOnly']) : state.getIn(['settings', 'public', 'other', 'allowLocalOnly']);
|
||||
const regex = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'regex', 'body']) : state.getIn(['settings', 'public', 'regex', 'body']);
|
||||
const timelineState = state.getIn(['timelines', `public${onlyMedia ? ':media' : ''}`]);
|
||||
|
||||
return {
|
||||
|
@ -28,6 +29,7 @@ const mapStateToProps = (state, { columnId }) => {
|
|||
onlyMedia,
|
||||
onlyRemote,
|
||||
allowLocalOnly,
|
||||
regex,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -52,6 +54,7 @@ class PublicTimeline extends React.PureComponent {
|
|||
onlyMedia: PropTypes.bool,
|
||||
onlyRemote: PropTypes.bool,
|
||||
allowLocalOnly: PropTypes.bool,
|
||||
regex: PropTypes.string,
|
||||
};
|
||||
|
||||
handlePin = () => {
|
||||
|
@ -133,6 +136,7 @@ class PublicTimeline extends React.PureComponent {
|
|||
scrollKey={`public_timeline-${columnId}`}
|
||||
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other servers to fill it up' />}
|
||||
bindToDocument={!multiColumn}
|
||||
regex={this.props.regex}
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
|
|
|
@ -6,20 +6,8 @@ import { createSelector } from 'reselect';
|
|||
import { debounce } from 'lodash';
|
||||
import { me } from 'flavours/glitch/util/initial_state';
|
||||
|
||||
const normalizeTimelineId = timelineId => {
|
||||
if (timelineId.startsWith('public:')) {
|
||||
return 'public';
|
||||
}
|
||||
|
||||
if (timelineId.startsWith('community:')) {
|
||||
return 'community';
|
||||
}
|
||||
|
||||
return timelineId;
|
||||
};
|
||||
|
||||
const getRegex = createSelector([
|
||||
(state, { type }) => state.getIn(['settings', normalizeTimelineId(type), 'regex', 'body']),
|
||||
(state, { regex }) => regex,
|
||||
], (rawRegex) => {
|
||||
let regex = null;
|
||||
|
||||
|
@ -32,7 +20,7 @@ const getRegex = createSelector([
|
|||
});
|
||||
|
||||
const makeGetStatusIds = (pending = false) => createSelector([
|
||||
(state, { type }) => state.getIn(['settings', normalizeTimelineId(type)], ImmutableMap()),
|
||||
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
|
||||
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
|
||||
(state) => state.get('statuses'),
|
||||
getRegex,
|
||||
|
@ -70,8 +58,8 @@ const makeMapStateToProps = () => {
|
|||
const getStatusIds = makeGetStatusIds();
|
||||
const getPendingStatusIds = makeGetStatusIds(true);
|
||||
|
||||
const mapStateToProps = (state, { timelineId }) => ({
|
||||
statusIds: getStatusIds(state, { type: timelineId }),
|
||||
const mapStateToProps = (state, { timelineId, regex }) => ({
|
||||
statusIds: getStatusIds(state, { type: timelineId, regex }),
|
||||
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true),
|
||||
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
|
||||
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
|
||||
|
|
Loading…
Reference in New Issue