import React, { Component } from 'react'; import { styles } from '../styles'; import { defineMessages, injectIntl } from 'react-intl'; import { log } from '/imports/ui/services/api'; import { notify } from '/imports/ui/services/notification'; import { toast } from 'react-toastify'; import { styles as mediaStyles } from '/imports/ui/components/media/styles'; import Toast from '/imports/ui/components/toast/component'; import _ from 'lodash'; import VideoElement from '../video-element/component'; const INITIAL_SHARE_WAIT_TIME = 2000; const intlMessages = defineMessages({ chromeExtensionError: { id: 'app.video.chromeExtensionError', description: 'Error message for Chrome Extension not installed', }, chromeExtensionErrorLink: { id: 'app.video.chromeExtensionErrorLink', description: 'Error message for Chrome Extension not installed', }, }); class VideoDock extends Component { constructor(props) { super(props); this.state = {}; } componentDidMount() { const { users, userId } = this.props; document.addEventListener('installChromeExtension', this.installChromeExtension.bind(this)); window.addEventListener('resize', this.adjustVideos); window.addEventListener('orientationchange', this.adjustVideos); } componentWillUnmount() { window.removeEventListener('resize', this.adjustVideos); window.removeEventListener('orientationchange', this.adjustVideos); document.removeEventListener('installChromeExtension', this.installChromeExtension.bind(this)); } componentDidUpdate() { this.adjustVideos(); } notifyError(message) { notify(message, 'error', 'video'); } installChromeExtension() { console.log(intlMessages); const { intl } = this.props; const CHROME_EXTENSION_LINK = Meteor.settings.public.kurento.chromeExtensionLink; this.notifyError(
{intl.formatMessage(intlMessages.chromeExtensionError)}{' '} {intl.formatMessage(intlMessages.chromeExtensionErrorLink)}
); } // TODO // Find a better place to put this piece of code adjustVideos() { setTimeout(() => { window.adjustVideos('webcamArea', true, mediaStyles.moreThan4Videos, mediaStyles.container, mediaStyles.overlayWrapper, 'presentationAreaData', 'screenshareVideo'); }, 0); } getUsersWithActiveStreams() { const { userId, sharedWebcam } = this.props; const activeFilter = (user) => { return user.has_stream || (sharedWebcam && user.userId == userId); }; return this.props.users.filter(activeFilter); } render() { if (!this.props.socketOpen) { // TODO: return something when disconnected return null; } const id = this.props.userId; const sharedWebcam = this.props.sharedWebcam; return (
{this.getUsersWithActiveStreams().map(user => ( ))}
); } } export default injectIntl(VideoDock);