gab-social/app/javascript/gabsocial/features/status.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-05-03 06:22:49 +01:00
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import { fetchStatus } from '../actions/statuses'
2020-04-29 23:32:49 +01:00
import StatusContainer from '../containers/status_container'
2020-05-03 06:22:49 +01:00
import ColumnIndicator from '../components/column_indicator'
const mapStateToProps = (state, props) => {
const statusId = props.id || props.params.statusId
return {
status: state.getIn(['statuses', statusId]),
}
}
const mapDispatchToProps = (dispatch) => ({
onFetchStatus: (id) => dispatch(fetchStatus(id)),
})
export default
@connect(mapStateToProps, mapDispatchToProps)
class Status extends ImmutablePureComponent {
static propTypes = {
onFetchStatus: PropTypes.func.isRequired,
params: PropTypes.object,
status: ImmutablePropTypes.map,
}
updateOnProps = [
'params',
'status',
]
componentDidMount() {
const statusId = this.props.id || this.props.params.statusId
this.props.onFetchStatus(statusId)
}
2020-04-29 23:32:49 +01:00
render() {
2020-05-03 06:22:49 +01:00
const { status } = this.props
2020-05-05 06:16:01 +01:00
2020-05-03 06:22:49 +01:00
if (!status) {
return <ColumnIndicator type='loading' />
}
2020-04-29 23:32:49 +01:00
return (
2020-05-04 19:44:37 +01:00
<StatusContainer {...this.props} contextType='feature' />
2020-04-29 23:32:49 +01:00
)
}
}