diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-08-28 17:16:30 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-08-31 18:35:03 +0200 |
commit | c6942a528332e99b605efa95ffa1c710324d368c (patch) | |
tree | 857b96004ccae2b5a7005afe681604db82661680 /app/javascript/flavours/glitch/components | |
parent | 5c400a28422121df01fc5ae73bc201f3b9aa5288 (diff) |
Add option to not automatically unfold content warnings matching a regexp
Fixes #678
Diffstat (limited to 'app/javascript/flavours/glitch/components')
-rw-r--r-- | app/javascript/flavours/glitch/components/status.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index e0d591ff6..9f47abfef 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -13,6 +13,7 @@ import { MediaGallery, Video } from 'flavours/glitch/util/async-components'; import { HotKeys } from 'react-hotkeys'; import NotificationOverlayContainer from 'flavours/glitch/features/notifications/containers/overlay_container'; import classNames from 'classnames'; +import { autoUnfoldCW } from 'flavours/glitch/util/content_warning'; // We use the component (and not the container) since we do not want // to use the progress bar to show download progress @@ -56,7 +57,7 @@ export default class Status extends ImmutablePureComponent { state = { isCollapsed: false, autoCollapsed: false, - isExpanded: this.props.settings.getIn(['content_warnings', 'auto_unfold']), + isExpanded: undefined, } // Avoid checking props that are functions (and whose equality will always @@ -124,6 +125,17 @@ export default class Status extends ImmutablePureComponent { updated = true; } + if (nextProps.expanded === undefined && + prevState.isExpanded === undefined && + update.isExpanded === undefined + ) { + const isExpanded = autoUnfoldCW(nextProps.settings, nextProps.status); + if (isExpanded !== undefined) { + update.isExpanded = isExpanded; + updated = true; + } + } + return updated ? update : null; } |