bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/chat/component.jsx

73 lines
1.8 KiB
React
Raw Normal View History

2016-04-29 03:02:51 +08:00
import React, { Component } from 'react';
import { Link } from 'react-router';
2016-06-02 00:33:19 +08:00
import styles from './styles';
import MessageForm from './message-form/component';
import MessageList from './message-list/component';
import Icon from '../icon/component';
2017-03-03 04:33:49 +08:00
import ChatService from './service';
2016-06-02 00:33:19 +08:00
const ELEMENT_ID = 'chat-messages';
2016-04-29 03:02:51 +08:00
export default class Chat extends Component {
2016-06-02 00:33:19 +08:00
constructor(props) {
super(props);
2017-03-01 06:40:16 +08:00
this.closeChat = this.closeChat.bind(this);
2016-06-02 00:33:19 +08:00
}
2016-04-29 03:02:51 +08:00
render() {
2016-06-02 00:33:19 +08:00
const {
2016-07-01 01:10:36 +08:00
chatID,
chatName,
2016-06-02 00:33:19 +08:00
title,
messages,
2016-07-01 01:10:36 +08:00
scrollPosition,
2016-07-05 21:34:13 +08:00
hasUnreadMessages,
2016-07-12 03:42:54 +08:00
lastReadMessageTime,
2016-06-07 22:19:19 +08:00
isChatLocked,
2016-06-03 02:40:27 +08:00
actions,
2016-06-02 00:33:19 +08:00
} = this.props;
2017-03-03 05:42:39 +08:00
return (
<section className={styles.chat}>
2017-03-01 06:40:16 +08:00
2017-03-03 05:42:39 +08:00
<header className={styles.header}>
<Link to="/users">
<Icon iconName="left-arrow"/> {title}
</Link>
2017-03-01 06:40:16 +08:00
2017-03-03 05:42:39 +08:00
{
((this.props.chatID == 'public') ?
null :
<Link to="/users">
<Icon iconName="close" onClick={this.closeChat} className={styles.closeIcon}/>
</Link>)
}
</header>
2017-03-01 06:40:16 +08:00
2016-06-02 00:33:19 +08:00
<MessageList
2016-07-01 01:10:36 +08:00
chatId={chatID}
2016-06-02 00:33:19 +08:00
messages={messages}
id={ELEMENT_ID}
2016-07-01 01:10:36 +08:00
scrollPosition={scrollPosition}
2016-07-05 21:34:13 +08:00
hasUnreadMessages={hasUnreadMessages}
2016-07-01 01:10:36 +08:00
handleScrollUpdate={actions.handleScrollUpdate}
2016-07-05 02:53:47 +08:00
handleReadMessage={actions.handleReadMessage}
2016-07-12 03:42:54 +08:00
lastReadMessageTime={lastReadMessageTime}
2016-06-02 00:33:19 +08:00
/>
2016-06-03 02:40:27 +08:00
<MessageForm
2016-06-07 22:19:19 +08:00
disabled={isChatLocked}
2016-06-03 02:40:27 +08:00
chatAreaId={ELEMENT_ID}
chatTitle={title}
chatName={chatName}
2016-06-03 02:40:27 +08:00
handleSendMessage={actions.handleSendMessage}
/>
2016-06-02 00:33:19 +08:00
</section>
2016-04-29 03:02:51 +08:00
);
}
2017-03-01 06:40:16 +08:00
closeChat() {
2017-03-03 04:33:49 +08:00
ChatService.createClosedChatSession(this.props.chatID);
2017-03-01 06:40:16 +08:00
}
2016-04-29 03:02:51 +08:00
}