mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-27 11:53:41 +01:00
Add regexp filter field to public timeline column settings (#1834)
* Add regexp filter field to public timeline column settings This has accidentally been removed while porting an upstream change years ago. * Remove dead code * Fix regexp filter not working for local and public TLs when using non-default settings
This commit is contained in:
parent
215738bb3c
commit
7a02c1d9ba
2 changed files with 28 additions and 7 deletions
|
@ -1,8 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
import SettingText from 'flavours/glitch/components/setting_text';
|
||||||
|
import SettingToggle from 'flavours/glitch/features/notifications/components/setting_toggle';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
filter_regex: { id: 'home.column_settings.filter_regex', defaultMessage: 'Filter out by regular expressions' },
|
||||||
|
});
|
||||||
|
|
||||||
export default @injectIntl
|
export default @injectIntl
|
||||||
class ColumnSettings extends React.PureComponent {
|
class ColumnSettings extends React.PureComponent {
|
||||||
|
@ -15,7 +20,7 @@ class ColumnSettings extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { settings, onChange } = this.props;
|
const { settings, onChange, intl } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -24,6 +29,12 @@ class ColumnSettings extends React.PureComponent {
|
||||||
<SettingToggle settings={settings} settingPath={['other', 'onlyRemote']} onChange={onChange} label={<FormattedMessage id='community.column_settings.remote_only' defaultMessage='Remote only' />} />
|
<SettingToggle settings={settings} settingPath={['other', 'onlyRemote']} onChange={onChange} label={<FormattedMessage id='community.column_settings.remote_only' defaultMessage='Remote only' />} />
|
||||||
{!settings.getIn(['other', 'onlyRemote']) && <SettingToggle settings={settings} settingPath={['other', 'allowLocalOnly']} onChange={onChange} label={<FormattedMessage id='community.column_settings.allow_local_only' defaultMessage='Show local-only toots' />} />}
|
{!settings.getIn(['other', 'onlyRemote']) && <SettingToggle settings={settings} settingPath={['other', 'allowLocalOnly']} onChange={onChange} label={<FormattedMessage id='community.column_settings.allow_local_only' defaultMessage='Show local-only toots' />} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
|
||||||
|
|
||||||
|
<div className='column-settings__row'>
|
||||||
|
<SettingText settings={settings} settingPath={['regex', 'body']} onChange={onChange} label={intl.formatMessage(messages.filter_regex)} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,20 @@ import { createSelector } from 'reselect';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { me } from 'flavours/glitch/util/initial_state';
|
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([
|
const getRegex = createSelector([
|
||||||
(state, { type }) => state.getIn(['settings', type, 'regex', 'body']),
|
(state, { type }) => state.getIn(['settings', normalizeTimelineId(type), 'regex', 'body']),
|
||||||
], (rawRegex) => {
|
], (rawRegex) => {
|
||||||
let regex = null;
|
let regex = null;
|
||||||
|
|
||||||
|
@ -20,13 +32,11 @@ const getRegex = createSelector([
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeGetStatusIds = (pending = false) => createSelector([
|
const makeGetStatusIds = (pending = false) => createSelector([
|
||||||
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
|
(state, { type }) => state.getIn(['settings', normalizeTimelineId(type)], ImmutableMap()),
|
||||||
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
|
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
|
||||||
(state) => state.get('statuses'),
|
(state) => state.get('statuses'),
|
||||||
getRegex,
|
getRegex,
|
||||||
], (columnSettings, statusIds, statuses, regex) => {
|
], (columnSettings, statusIds, statuses, regex) => {
|
||||||
const rawRegex = columnSettings.getIn(['regex', 'body'], '').trim();
|
|
||||||
|
|
||||||
return statusIds.filter(id => {
|
return statusIds.filter(id => {
|
||||||
if (id === null) return true;
|
if (id === null) return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue