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

56 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-11-15 18:48:32 +00:00
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import ChatEmptyMessageBlock from './components/chat_conversations_empty_block'
import ChatMessageHeader from './components/chat_message_header'
import ChatMessageScrollingList from './components/chat_message_scrolling_list'
import ChatMessagesComposeForm from './components/chat_message_compose_form'
2020-11-15 18:48:32 +00:00
class Messages extends React.PureComponent {
render () {
const {
isXS,
selectedChatConversationId,
chatConverationIsRequest,
} = this.props
2020-11-15 18:48:32 +00:00
return (
<div className={[_s.d, _s.bgPrimary, _s.h100PC, _s.w100PC].join(' ')}>
{
!selectedChatConversationId &&
<ChatEmptyMessageBlock />
2020-11-15 18:48:32 +00:00
}
{
!!selectedChatConversationId &&
2020-11-15 18:48:32 +00:00
<div className={[_s.d, _s.h100PC, _s.w100PC].join(' ')}>
<ChatMessageHeader chatConversationId={selectedChatConversationId} />
<ChatMessageScrollingList chatConversationId={selectedChatConversationId} />
{
!chatConverationIsRequest &&
<ChatMessagesComposeForm chatConversationId={selectedChatConversationId} />
}
2020-11-15 18:48:32 +00:00
</div>
}
</div>
)
}
}
const mapStateToProps = (state, props) => {
const selectedChatConversationId = state.getIn(['chats', 'selectedChatConversationId'], null)
const chatConverationIsRequest = selectedChatConversationId ? !state.getIn(['chat_conversations', selectedChatConversationId, 'is_approved'], null) : false
return {
selectedChatConversationId,
chatConverationIsRequest,
}
}
2020-11-15 18:48:32 +00:00
Messages.propTypes = {
isXS: PropTypes.bool,
selectedChatConversationId: PropTypes.string,
chatConverationIsRequest: PropTypes.bool.isRequired,
2020-11-15 18:48:32 +00:00
}
export default connect(mapStateToProps)(Messages)