logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

status_check_box.js (2208B)


  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import Toggle from 'react-toggle';
  5. import noop from 'lodash/noop';
  6. import StatusContent from '../../../components/status_content';
  7. import { MediaGallery, Video } from '../../ui/util/async-components';
  8. import Bundle from '../../ui/components/bundle';
  9. export default class StatusCheckBox extends React.PureComponent {
  10. static propTypes = {
  11. status: ImmutablePropTypes.map.isRequired,
  12. checked: PropTypes.bool,
  13. onToggle: PropTypes.func.isRequired,
  14. disabled: PropTypes.bool,
  15. };
  16. render () {
  17. const { status, checked, onToggle, disabled } = this.props;
  18. let media = null;
  19. if (status.get('reblog')) {
  20. return null;
  21. }
  22. if (status.get('media_attachments').size > 0) {
  23. if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
  24. } else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  25. const video = status.getIn(['media_attachments', 0]);
  26. media = (
  27. <Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
  28. {Component => (
  29. <Component
  30. preview={video.get('preview_url')}
  31. src={video.get('url')}
  32. width={239}
  33. height={110}
  34. inline
  35. sensitive={status.get('sensitive')}
  36. onOpenVideo={noop}
  37. />
  38. )}
  39. </Bundle>
  40. );
  41. } else {
  42. media = (
  43. <Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery} >
  44. {Component => <Component media={status.get('media_attachments')} sensitive={status.get('sensitive')} height={110} onOpenMedia={noop} />}
  45. </Bundle>
  46. );
  47. }
  48. }
  49. return (
  50. <div className='status-check-box'>
  51. <div className='status-check-box__status'>
  52. <StatusContent status={status} />
  53. {media}
  54. </div>
  55. <div className='status-check-box-toggle'>
  56. <Toggle checked={checked} onChange={onToggle} disabled={disabled} />
  57. </div>
  58. </div>
  59. );
  60. }
  61. }