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:
Claire
2022-08-28 22:21:55 +02:00
committed by GitHub
parent 215738bb3c
commit 7a02c1d9ba
2 changed files with 28 additions and 7 deletions

View File

@@ -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;