diff --git a/app/soapbox/components/status.js b/app/soapbox/components/status.js index fcdddccb2..1bc5b5175 100644 --- a/app/soapbox/components/status.js +++ b/app/soapbox/components/status.js @@ -16,7 +16,6 @@ import { MediaGallery, Video, Audio } from '../features/ui/util/async-components import { HotKeys } from 'react-hotkeys'; import classNames from 'classnames'; import Icon from 'soapbox/components/icon'; -import PollContainer from 'soapbox/containers/poll_container'; import { Link, NavLink } from 'react-router-dom'; import { getDomain } from 'soapbox/utils/accounts'; import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper'; @@ -361,10 +360,6 @@ class Status extends ImmutablePureComponent { status = status.get('reblog'); } - if (status.get('poll')) { - poll = ; - } - const size = status.get('media_attachments').size; if (size > 0) { diff --git a/app/soapbox/components/status_content.js b/app/soapbox/components/status_content.js index 4913b5eb9..0473e600a 100644 --- a/app/soapbox/components/status_content.js +++ b/app/soapbox/components/status_content.js @@ -6,6 +6,7 @@ import { isRtl } from '../rtl'; import { FormattedMessage } from 'react-intl'; import Permalink from './permalink'; import classnames from 'classnames'; +import PollContainer from 'soapbox/containers/poll_container'; import Icon from 'soapbox/components/icon'; import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import { addGreentext } from 'soapbox/utils/greentext'; @@ -240,6 +241,8 @@ class StatusContent extends React.PureComponent { {mentionsPlaceholder}
+ + {!hidden && !!status.get('poll') && }
); } else if (this.props.onClick) { @@ -261,9 +264,13 @@ 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/soapbox/features/scheduled_statuses/components/poll_preview.js b/app/soapbox/features/scheduled_statuses/components/poll_preview.js new file mode 100644 index 000000000..32b7231b2 --- /dev/null +++ b/app/soapbox/features/scheduled_statuses/components/poll_preview.js @@ -0,0 +1,50 @@ +import React from 'react'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import classNames from 'classnames'; + +export default class PollPreview extends ImmutablePureComponent { + + static propTypes = { + poll: ImmutablePropTypes.map, + }; + + renderOption(option) { + const { poll } = this.props; + const showResults = poll.get('voted') || poll.get('expired'); + + return ( +
  • + +
  • + ); + } + + render() { + const { poll } = this.props; + + if (!poll) { + return null; + } + + return ( +
    +
      + {poll.get('options').map((option, i) => this.renderOption(option, i))} +
    +
    + ); + } + +} diff --git a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js index c0fd0ffd8..b8f3e825e 100644 --- a/app/soapbox/features/scheduled_statuses/components/scheduled_status.js +++ b/app/soapbox/features/scheduled_statuses/components/scheduled_status.js @@ -11,7 +11,7 @@ import { getDomain } from 'soapbox/utils/accounts'; import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display_name'; import AttachmentList from 'soapbox/components/attachment_list'; -import PollContainer from 'soapbox/containers/poll_container'; +import PollPreview from './poll_preview'; import ScheduledStatusActionBar from './scheduled_status_action_bar'; const mapStateToProps = (state, props) => { @@ -72,7 +72,7 @@ class ScheduledStatus extends ImmutablePureComponent { media={status.get('media_attachments')} /> - {status.get('poll') && } + {status.get('poll') && } {showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && (