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.
64 lines
1.5 KiB
64 lines
1.5 KiB
import React from 'react'; |
|
import PropTypes from 'prop-types'; |
|
import ImmutablePropTypes from 'react-immutable-proptypes'; |
|
import ImmutablePureComponent from 'react-immutable-pure-component'; |
|
import StatusContainer from '../../../containers/status_container'; |
|
|
|
export default class Conversation extends ImmutablePureComponent { |
|
|
|
static contextTypes = { |
|
router: PropTypes.object, |
|
}; |
|
|
|
static propTypes = { |
|
conversationId: PropTypes.string.isRequired, |
|
accounts: ImmutablePropTypes.list.isRequired, |
|
lastStatusId: PropTypes.string, |
|
unread:PropTypes.bool.isRequired, |
|
onMoveUp: PropTypes.func, |
|
onMoveDown: PropTypes.func, |
|
markRead: PropTypes.func.isRequired, |
|
}; |
|
|
|
handleClick = () => { |
|
if (!this.context.router) { |
|
return; |
|
} |
|
|
|
const { lastStatusId, unread, markRead } = this.props; |
|
|
|
if (unread) { |
|
markRead(); |
|
} |
|
|
|
this.context.router.history.push(`/statuses/${lastStatusId}`); |
|
} |
|
|
|
handleHotkeyMoveUp = () => { |
|
this.props.onMoveUp(this.props.conversationId); |
|
} |
|
|
|
handleHotkeyMoveDown = () => { |
|
this.props.onMoveDown(this.props.conversationId); |
|
} |
|
|
|
render () { |
|
const { accounts, lastStatusId, unread } = this.props; |
|
|
|
if (lastStatusId === null) { |
|
return null; |
|
} |
|
|
|
return ( |
|
<StatusContainer |
|
id={lastStatusId} |
|
unread={unread} |
|
otherAccounts={accounts} |
|
onMoveUp={this.handleHotkeyMoveUp} |
|
onMoveDown={this.handleHotkeyMoveDown} |
|
onClick={this.handleClick} |
|
/> |
|
); |
|
} |
|
|
|
}
|
|
|