The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

74 lines
2.3 KiB

  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. blurhash={video.get('blurhash')}
  32. src={video.get('url')}
  33. alt={video.get('description')}
  34. width={239}
  35. height={110}
  36. inline
  37. sensitive={status.get('sensitive')}
  38. onOpenVideo={noop}
  39. />
  40. )}
  41. </Bundle>
  42. );
  43. } else {
  44. media = (
  45. <Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery} >
  46. {Component => <Component media={status.get('media_attachments')} sensitive={status.get('sensitive')} height={110} onOpenMedia={noop} />}
  47. </Bundle>
  48. );
  49. }
  50. }
  51. return (
  52. <div className='status-check-box'>
  53. <div className='status-check-box__status'>
  54. <StatusContent status={status} />
  55. {media}
  56. </div>
  57. <div className='status-check-box-toggle'>
  58. <Toggle checked={checked} onChange={onToggle} disabled={disabled} />
  59. </div>
  60. </div>
  61. );
  62. }
  63. }