From e9ddd5a159c821e3fb75ff997f40a4bca35c326c Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 8 Jun 2019 17:40:59 +0200 Subject: Put poll options behind content warnings (#10983) * Put poll options behind CWs in WebUI * Put polls behind CWs on public pages * Add poll icon to public pages CWs * Revert to not showing an icon in the CW button --- app/javascript/mastodon/components/status.js | 5 +---- app/javascript/mastodon/components/status_content.js | 19 ++++++++++++++++--- .../features/status/components/detailed_status.js | 5 +---- app/javascript/packs/public.js | 8 ++++---- 4 files changed, 22 insertions(+), 15 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 6e944dc9e..a795b8ce9 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -16,7 +16,6 @@ import { MediaGallery, Video } from '../features/ui/util/async-components'; import { HotKeys } from 'react-hotkeys'; import classNames from 'classnames'; import Icon from 'mastodon/components/icon'; -import PollContainer from 'mastodon/containers/poll_container'; import { displayMedia } from '../initial_state'; // We use the component (and not the container) since we do not want @@ -321,9 +320,7 @@ class Status extends ImmutablePureComponent { status = status.get('reblog'); } - if (status.get('poll')) { - media = ; - } else if (status.get('media_attachments').size > 0) { + if (status.get('media_attachments').size > 0) { if (this.props.muted) { media = ( + + {!hidden && !!status.get('poll') && } ); } else if (this.props.onClick) { @@ -212,9 +215,13 @@ export default class StatusContent extends React.PureComponent { output.push(readMoreButton); } + if (status.get('poll')) { + output.push(); + } + return output; } else { - return ( + const output = [
- ); + />, + ]; + + if (status.get('poll')) { + output.push(); + } + + return output; } } diff --git a/app/javascript/mastodon/features/status/components/detailed_status.js b/app/javascript/mastodon/features/status/components/detailed_status.js index 9089eb303..c7aa4d033 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@ -13,7 +13,6 @@ import Video from '../../video'; import scheduleIdleTask from '../../ui/util/schedule_idle_task'; import classNames from 'classnames'; import Icon from 'mastodon/components/icon'; -import PollContainer from 'mastodon/containers/poll_container'; export default class DetailedStatus extends ImmutablePureComponent { @@ -107,9 +106,7 @@ export default class DetailedStatus extends ImmutablePureComponent { outerStyle.height = `${this.state.height}px`; } - if (status.get('poll')) { - media = ; - } else if (status.get('media_attachments').size > 0) { + if (status.get('media_attachments').size > 0) { if (status.getIn(['media_attachments', 0, 'type']) === 'video') { const video = status.getIn(['media_attachments', 0]); diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 93379cdb3..3135636cf 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -126,15 +126,15 @@ function main() { return false; }); - delegate(document, '.status__content__spoiler-link', 'click', ({ target }) => { - const contentEl = target.parentNode.parentNode.querySelector('.e-content'); + delegate(document, '.status__content__spoiler-link', 'click', function() { + const contentEl = this.parentNode.parentNode.querySelector('.e-content'); if (contentEl.style.display === 'block') { contentEl.style.display = 'none'; - target.parentNode.style.marginBottom = 0; + this.parentNode.style.marginBottom = 0; } else { contentEl.style.display = 'block'; - target.parentNode.style.marginBottom = null; + this.parentNode.style.marginBottom = null; } return false; -- cgit