2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-07-16 05:00:19 +01:00
|
|
|
import { NavLink } from 'react-router-dom'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import { fetchStatus } from '../../actions/statuses'
|
|
|
|
import { makeGetStatus } from '../../selectors'
|
|
|
|
import { me } from '../../initial_state'
|
|
|
|
import {
|
|
|
|
CX,
|
|
|
|
} from '../../constants'
|
|
|
|
import PanelLayout from './panel_layout'
|
|
|
|
import Avatar from '../avatar'
|
|
|
|
import Button from '../button'
|
|
|
|
import DisplayName from '../display_name'
|
|
|
|
import ColumnIndicator from '../column_indicator'
|
|
|
|
import StatusContent from '../status_content'
|
|
|
|
import StatusMedia from '../status_media'
|
|
|
|
|
|
|
|
class StatusPromotionPanel extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
if (!this.props.status) {
|
|
|
|
this.props.onFetchStatus(this.props.statusId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { status } = this.props
|
|
|
|
|
|
|
|
const containerClasses = CX({
|
2020-08-18 21:49:11 +01:00
|
|
|
d: 1,
|
2020-07-16 05:00:19 +01:00
|
|
|
pb10: !!status ? status.get('media_attachments').size === 0 : false,
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PanelLayout noPadding>
|
|
|
|
{
|
|
|
|
!status && <ColumnIndicator type='loading' />
|
|
|
|
}
|
|
|
|
{
|
|
|
|
!!status &&
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={_s.d}>
|
|
|
|
<div className={[_s.d, _s.px15, _s.py10].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.flexRow, _s.mt5].join(' ')}>
|
2020-07-16 05:00:19 +01:00
|
|
|
|
|
|
|
<NavLink
|
|
|
|
to={`/${status.getIn(['account', 'acct'])}`}
|
|
|
|
title={status.getIn(['account', 'acct'])}
|
2020-08-18 21:49:11 +01:00
|
|
|
className={[_s.d, _s.mr10].join(' ')}
|
2020-07-16 05:00:19 +01:00
|
|
|
>
|
|
|
|
<Avatar account={status.get('account')} size={28} />
|
|
|
|
</NavLink>
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.aiStart, _s.flexGrow1, _s.mt5].join(' ')}>
|
2020-07-16 05:00:19 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.flexRow, _s.w100PC, _s.aiStart].join(' ')}>
|
2020-07-16 05:00:19 +01:00
|
|
|
<NavLink
|
2020-08-18 21:49:11 +01:00
|
|
|
className={[_s.d, _s.flexRow, _s.aiStart, _s.noUnderline].join(' ')}
|
2020-07-16 05:00:19 +01:00
|
|
|
to={`/${status.getIn(['account', 'acct'])}`}
|
|
|
|
title={status.getIn(['account', 'acct'])}
|
|
|
|
>
|
|
|
|
<DisplayName account={status.get('account')} noRelationship />
|
|
|
|
</NavLink>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
isText
|
|
|
|
backgroundColor='none'
|
|
|
|
color='none'
|
|
|
|
icon='ellipsis'
|
|
|
|
iconSize='20px'
|
2020-08-18 21:43:06 +01:00
|
|
|
iconClassName={_s.cSecondary}
|
2020-07-16 05:00:19 +01:00
|
|
|
className={_s.mlAuto}
|
|
|
|
onClick={() => {}}
|
|
|
|
// buttonRef={this.setStatusOptionsButton}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={containerClasses}>
|
|
|
|
<StatusContent
|
|
|
|
status={status}
|
|
|
|
expanded={!status.get('hidden')}
|
|
|
|
collapsable
|
|
|
|
onClick={() => { }}
|
|
|
|
onExpandedToggle={() => { }}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<StatusMedia
|
|
|
|
status={status}
|
|
|
|
onOpenMedia={() => { }}
|
|
|
|
onToggleVisibility={() => { }}
|
|
|
|
onOpenVideo={() => { }}
|
2020-08-06 05:27:35 +01:00
|
|
|
isStatusCard
|
2020-07-16 05:00:19 +01:00
|
|
|
// width={this.props.cachedMediaWidth}
|
|
|
|
// cacheWidth={this.props.cacheMediaWidth}
|
|
|
|
// defaultWidth={this.props.cachedMediaWidth}
|
|
|
|
// visible={this.state.showMedia}
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</PanelLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { statusId }) => ({
|
|
|
|
status: makeGetStatus()(state, { id: statusId }),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onFetchStatus: (id) => dispatch(fetchStatus(id)),
|
|
|
|
})
|
|
|
|
|
|
|
|
StatusPromotionPanel.propTypes = {
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
statusId: PropTypes.string.isRequired,
|
|
|
|
onFetchStatus: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(StatusPromotionPanel)
|