2016-09-01 21:56:41 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2016-07-29 03:48:26 +08:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-09-01 21:56:41 +08:00
|
|
|
|
2016-07-29 03:48:26 +08:00
|
|
|
import LoadingScreen from '../loading-screen/component';
|
|
|
|
import KickedScreen from '../kicked-screen/component';
|
2016-08-10 00:28:16 +08:00
|
|
|
|
|
|
|
import NotificationsBarContainer from '../notifications-bar/container';
|
2017-01-26 03:52:17 +08:00
|
|
|
import AudioNotificationContainer from '../audio-notification/container';
|
2016-08-10 00:28:16 +08:00
|
|
|
|
2017-01-25 06:32:25 +08:00
|
|
|
import LocalStorage from '/imports/ui/services/storage/local.js';
|
2016-08-10 00:28:16 +08:00
|
|
|
|
2016-07-29 03:48:26 +08:00
|
|
|
import Button from '../button/component';
|
2016-05-03 06:42:54 +08:00
|
|
|
import styles from './styles';
|
2016-08-25 02:56:06 +08:00
|
|
|
import cx from 'classnames';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
navbar: PropTypes.element,
|
|
|
|
sidebar: PropTypes.element,
|
|
|
|
sidebarRight: PropTypes.element,
|
|
|
|
media: PropTypes.element,
|
|
|
|
actionsbar: PropTypes.element,
|
2016-07-23 08:12:31 +08:00
|
|
|
captions: PropTypes.element,
|
2016-09-01 21:56:41 +08:00
|
|
|
modal: PropTypes.element,
|
2017-01-14 07:57:29 +08:00
|
|
|
unreadMessageCount: PropTypes.array,
|
2017-01-17 02:03:02 +08:00
|
|
|
openChats: PropTypes.array,
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default class App extends Component {
|
2016-09-15 01:48:50 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
compactUserList: false, //TODO: Change this on userlist resize (?)
|
|
|
|
};
|
2017-02-25 04:19:53 +08:00
|
|
|
|
|
|
|
this.setDefaultSettings = props.setDefaultSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
setHtmlFontSize(size) {
|
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = size;
|
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.setDefaultSettings();
|
|
|
|
this.setHtmlFontSize(this.props.fontSize);
|
2016-09-15 01:48:50 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
renderNavBar() {
|
2016-04-29 03:02:51 +08:00
|
|
|
const { navbar } = this.props;
|
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
if (navbar) {
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={styles.navbar}>
|
2016-04-29 03:02:51 +08:00
|
|
|
{navbar}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2016-04-29 03:02:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
renderSidebar() {
|
|
|
|
const { sidebar } = this.props;
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
if (sidebar) {
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2016-05-04 04:40:46 +08:00
|
|
|
<aside className={styles.sidebar}>
|
2016-04-29 03:02:51 +08:00
|
|
|
{sidebar}
|
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
renderUserList() {
|
2016-09-15 01:48:50 +08:00
|
|
|
let { userList } = this.props;
|
|
|
|
const { compactUserList } = this.state;
|
2016-08-25 02:56:06 +08:00
|
|
|
|
2016-09-15 01:48:50 +08:00
|
|
|
let userListStyle = {};
|
|
|
|
userListStyle[styles.compact] = compactUserList;
|
2016-05-04 04:40:46 +08:00
|
|
|
if (userList) {
|
2016-09-15 01:48:50 +08:00
|
|
|
userList = React.cloneElement(userList, {
|
|
|
|
compact: compactUserList,
|
|
|
|
});
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={cx(styles.userList, userListStyle)} role="region" aria-label="user list">
|
2016-05-04 04:40:46 +08:00
|
|
|
{userList}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2016-05-04 04:40:46 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderChat() {
|
|
|
|
const { chat } = this.props;
|
|
|
|
|
|
|
|
if (chat) {
|
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={styles.chat} role="region" aria-label="chat">
|
2016-05-04 04:40:46 +08:00
|
|
|
{chat}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2016-05-04 04:40:46 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
renderMedia() {
|
|
|
|
const { media } = this.props;
|
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
if (media) {
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={styles.media} role="region" aria-label="media">
|
2016-04-29 03:02:51 +08:00
|
|
|
{media}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2016-04-29 03:02:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-23 08:12:31 +08:00
|
|
|
renderClosedCaptions() {
|
|
|
|
const { captions } = this.props;
|
2017-02-25 04:19:53 +08:00
|
|
|
if (captions && this.props.getCaptionsStatus()) {
|
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={styles.closedCaptions} role="region" aria-label="Closed Captions">
|
2017-02-25 04:19:53 +08:00
|
|
|
{captions}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2017-02-25 04:19:53 +08:00
|
|
|
);
|
2016-07-23 08:12:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
renderActionsBar() {
|
2016-04-29 03:02:51 +08:00
|
|
|
const { actionsbar } = this.props;
|
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
if (actionsbar) {
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<div className={styles.actionsbar} role="region" aria-label="actions bar">
|
2016-04-29 03:02:51 +08:00
|
|
|
{actionsbar}
|
2017-03-15 23:24:57 +08:00
|
|
|
</div>
|
2016-04-29 03:02:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-12 04:43:07 +08:00
|
|
|
renderAudioElement() {
|
|
|
|
return (
|
2016-07-05 08:06:18 +08:00
|
|
|
<audio id="remote-media" autoPlay="autoplay"></audio>
|
2016-05-12 04:43:07 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-01 21:56:41 +08:00
|
|
|
renderModal() {
|
|
|
|
const { modal } = this.props;
|
|
|
|
|
|
|
|
if (modal) {
|
|
|
|
return (<div>{modal}</div>);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-17 02:03:02 +08:00
|
|
|
playSoundForUnreadMessages() {
|
2017-01-14 07:57:29 +08:00
|
|
|
const snd = new Audio('/html5client/resources/sounds/notify.mp3');
|
|
|
|
snd.play();
|
2016-12-23 07:34:20 +08:00
|
|
|
}
|
|
|
|
|
2017-01-17 05:24:21 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
2017-01-14 07:57:29 +08:00
|
|
|
|
2017-01-17 02:03:02 +08:00
|
|
|
let { unreadMessageCount, openChats, openChat } = this.props;
|
2017-01-21 01:50:03 +08:00
|
|
|
|
2017-01-17 02:03:02 +08:00
|
|
|
unreadMessageCount.forEach((chat, i) => {
|
2017-01-17 05:24:21 +08:00
|
|
|
// When starting the new chat, if prevProps is undefined or null, it is assigned 0.
|
|
|
|
if (!prevProps.unreadMessageCount[i]) {
|
2017-01-16 23:56:21 +08:00
|
|
|
prevProps.unreadMessageCount[i] = 0;
|
|
|
|
}
|
|
|
|
|
2017-01-17 05:24:21 +08:00
|
|
|
// compare openChats(chatID) to chatID of currently opened chat room
|
|
|
|
if (openChats[i] !== openChat) {
|
2017-03-09 22:34:33 +08:00
|
|
|
let shouldPlaySound = this.props.applicationSettings.chatAudioNotifications;
|
|
|
|
|
2017-01-25 06:32:25 +08:00
|
|
|
if (shouldPlaySound && chat > prevProps.unreadMessageCount[i]) {
|
2017-01-17 02:03:02 +08:00
|
|
|
this.playSoundForUnreadMessages();
|
2017-01-14 07:57:29 +08:00
|
|
|
}
|
|
|
|
}
|
2017-01-17 02:03:02 +08:00
|
|
|
});
|
2017-01-14 07:57:29 +08:00
|
|
|
}
|
2016-12-23 07:34:20 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
render() {
|
2016-07-29 03:48:26 +08:00
|
|
|
if (this.props.wasKicked) {
|
|
|
|
return (
|
|
|
|
<KickedScreen>
|
|
|
|
<FormattedMessage
|
|
|
|
id="app.kickMessage"
|
|
|
|
description="Message when the user is kicked out of the meeting"
|
|
|
|
defaultMessage="You have been kicked out of the meeting"
|
|
|
|
/>
|
|
|
|
<br/><br/>
|
|
|
|
<Button
|
|
|
|
label={'OK'}
|
|
|
|
onClick={this.props.redirectToLogoutUrl}/>
|
|
|
|
</KickedScreen>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-07-09 07:13:26 +08:00
|
|
|
if (this.props.isLoading) {
|
2016-07-29 03:48:26 +08:00
|
|
|
return <LoadingScreen/>;
|
2016-07-07 22:01:40 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2017-03-15 23:24:57 +08:00
|
|
|
<main className={styles.main} role="main">
|
2017-01-26 03:52:17 +08:00
|
|
|
<AudioNotificationContainer />
|
2016-08-10 00:28:16 +08:00
|
|
|
<NotificationsBarContainer />
|
2016-05-03 06:42:54 +08:00
|
|
|
<section className={styles.wrapper}>
|
2016-05-04 04:40:46 +08:00
|
|
|
{this.renderUserList()}
|
|
|
|
{this.renderChat()}
|
2016-05-03 06:42:54 +08:00
|
|
|
<div className={styles.content}>
|
2016-05-04 22:48:53 +08:00
|
|
|
{this.renderNavBar()}
|
2016-04-29 03:02:51 +08:00
|
|
|
{this.renderMedia()}
|
2016-05-04 22:48:53 +08:00
|
|
|
{this.renderActionsBar()}
|
2016-04-29 03:02:51 +08:00
|
|
|
</div>
|
2016-05-04 04:40:46 +08:00
|
|
|
{this.renderSidebar()}
|
2016-12-21 07:54:39 +08:00
|
|
|
{this.renderClosedCaptions()}
|
2016-04-29 03:02:51 +08:00
|
|
|
</section>
|
2016-05-12 04:43:07 +08:00
|
|
|
{this.renderAudioElement()}
|
2016-09-01 21:56:41 +08:00
|
|
|
{this.renderModal()}
|
2016-04-29 03:02:51 +08:00
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = propTypes;
|