From 7a02c1d9bab8ba004eea54a907782a949ecb3493 Mon Sep 17 00:00:00 2001 From: Claire Date: Sun, 28 Aug 2022 22:21:55 +0200 Subject: 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 --- .../public_timeline/components/column_settings.js | 17 ++++++++++++++--- .../features/ui/containers/status_list_container.js | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/features/public_timeline/components/column_settings.js b/app/javascript/flavours/glitch/features/public_timeline/components/column_settings.js index e92681065..cfe821cfc 100644 --- a/app/javascript/flavours/glitch/features/public_timeline/components/column_settings.js +++ b/app/javascript/flavours/glitch/features/public_timeline/components/column_settings.js @@ -1,8 +1,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import { injectIntl, FormattedMessage } from 'react-intl'; -import SettingToggle from '../../notifications/components/setting_toggle'; +import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +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 class ColumnSettings extends React.PureComponent { @@ -15,7 +20,7 @@ class ColumnSettings extends React.PureComponent { }; render () { - const { settings, onChange } = this.props; + const { settings, onChange, intl } = this.props; return (
@@ -24,6 +29,12 @@ class ColumnSettings extends React.PureComponent { } /> {!settings.getIn(['other', 'onlyRemote']) && } />}
+ + + +
+ +
); } diff --git a/app/javascript/flavours/glitch/features/ui/containers/status_list_container.js b/app/javascript/flavours/glitch/features/ui/containers/status_list_container.js index bd2d2eb4e..0828e3cb0 100644 --- a/app/javascript/flavours/glitch/features/ui/containers/status_list_container.js +++ b/app/javascript/flavours/glitch/features/ui/containers/status_list_container.js @@ -6,8 +6,20 @@ 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', type, 'regex', 'body']), + (state, { type }) => state.getIn(['settings', normalizeTimelineId(type), 'regex', 'body']), ], (rawRegex) => { let regex = null; @@ -20,13 +32,11 @@ const getRegex = 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) => state.get('statuses'), getRegex, ], (columnSettings, statusIds, statuses, regex) => { - const rawRegex = columnSettings.getIn(['regex', 'body'], '').trim(); - return statusIds.filter(id => { if (id === null) return true; -- cgit