mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-26 00:34:01 +00:00
* ui: check spoiler_text against regex filter (#1635) When filtering by regex, also check the spoiler_text if present. * ui: concatenate spoiler and content in reducer Simplifies aa5b03c, clarifies intent of the field
This commit is contained in:
parent
f9d398e8fb
commit
61c33652ad
|
@ -26,7 +26,7 @@ const makeGetStatusIds = () => createSelector([
|
||||||
try {
|
try {
|
||||||
if (showStatus) {
|
if (showStatus) {
|
||||||
const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i');
|
const regex = new RegExp(columnSettings.getIn(['regex', 'body']).trim(), 'i');
|
||||||
showStatus = !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'unescaped_content']) : statusForId.get('unescaped_content'));
|
showStatus = !regex.test(statusForId.get('reblog') ? statuses.getIn([statusForId.get('reblog'), 'search_index']) : statusForId.get('search_index'));
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// Bad regex, don't affect filters
|
// Bad regex, don't affect filters
|
||||||
|
|
|
@ -48,8 +48,8 @@ const normalizeStatus = (state, status) => {
|
||||||
normalStatus.reblog = status.reblog.id;
|
normalStatus.reblog = status.reblog.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const linebreakComplemented = status.content.replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||||
normalStatus.unescaped_content = new DOMParser().parseFromString(linebreakComplemented, 'text/html').documentElement.textContent;
|
normalStatus.search_index = new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent;
|
||||||
|
|
||||||
return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
|
return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue