about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorR Tucker <github@ryantucker.us>2017-05-04 17:48:48 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-04 23:48:48 +0200
commit61c33652ad7a98f0c30fea67bc382e1306b69880 (patch)
tree71a82b7e89d8dc7567a21229ff3df651af1c5afe /app/javascript
parentf9d398e8fb2fe17694949ec1654df60298b0004b (diff)
ui: check spoiler_text against regex filter (#1635) (#2665)
* 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
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/features/ui/containers/status_list_container.js2
-rw-r--r--app/javascript/mastodon/reducers/statuses.js4
2 files changed, 3 insertions, 3 deletions
diff --git a/app/javascript/mastodon/features/ui/containers/status_list_container.js b/app/javascript/mastodon/features/ui/containers/status_list_container.js
index 1599000b5..131f5192a 100644
--- a/app/javascript/mastodon/features/ui/containers/status_list_container.js
+++ b/app/javascript/mastodon/features/ui/containers/status_list_container.js
@@ -26,7 +26,7 @@ const makeGetStatusIds = () => createSelector([
     try {
       if (showStatus) {
         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) {
       // Bad regex, don't affect filters
diff --git a/app/javascript/mastodon/reducers/statuses.js b/app/javascript/mastodon/reducers/statuses.js
index 2002d2223..3ad924c69 100644
--- a/app/javascript/mastodon/reducers/statuses.js
+++ b/app/javascript/mastodon/reducers/statuses.js
@@ -48,8 +48,8 @@ const normalizeStatus = (state, status) => {
     normalStatus.reblog = status.reblog.id;
   }
 
-  const linebreakComplemented = status.content.replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
-  normalStatus.unescaped_content = new DOMParser().parseFromString(linebreakComplemented, 'text/html').documentElement.textContent;
+  const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
+  normalStatus.search_index = new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent;
 
   return state.update(status.id, Immutable.Map(), map => map.mergeDeep(Immutable.fromJS(normalStatus)));
 };