diff options
| author | Roger Braun <roger@rogerbraun.net> | 2017-06-18 19:19:17 +0200 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2017-06-18 19:19:17 +0200 |
| commit | 8e5d17a659b157f095ad3850ac3cdd2e537ac38b (patch) | |
| tree | 5051933d8a9a61a72168d36e54dd8011aa50d458 /src | |
| parent | 7d93546d980aea499257b6b0b6dd6af6c60c26d0 (diff) | |
Use tags array in status if available.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/statuses.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index c3753c5a..084800fa 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,4 +1,4 @@ -import { remove, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max, isArray } from 'lodash' +import { includes, remove, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max, isArray } from 'lodash' import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' @@ -68,11 +68,15 @@ export const defaultState = { } } +const isNsfw = (status) => { + const nsfwRegex = /#nsfw/i + return includes(status.tags, 'nsfw') || !!status.text.match(nsfwRegex) +} + export const prepareStatus = (status) => { // Parse nsfw tags if (status.nsfw === undefined) { - const nsfwRegex = /#nsfw/i - status.nsfw = !!status.text.match(nsfwRegex) + status.nsfw = isNsfw(status) } // Set deleted flag |
