2017-10-13 02:53:33 +08:00
|
|
|
import React from 'react';
|
2017-11-22 21:11:21 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2017-10-19 03:24:26 +08:00
|
|
|
import { ToastContainer as Toastify } from 'react-toastify';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2017-10-19 03:24:26 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-10-21 03:27:00 +08:00
|
|
|
import injectNotify from '/imports/ui/components/toast/inject-notify/component';
|
2017-10-13 02:53:33 +08:00
|
|
|
|
2017-10-19 18:45:07 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
2017-10-13 02:53:33 +08:00
|
|
|
|
|
|
|
import Icon from '../icon/component';
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from './styles';
|
2017-10-13 02:53:33 +08:00
|
|
|
|
2017-10-19 03:24:26 +08:00
|
|
|
const intlMessages = defineMessages({
|
2017-11-22 21:11:21 +08:00
|
|
|
|
2017-10-19 03:24:26 +08:00
|
|
|
toastBreakoutRoomEnded: {
|
2017-12-18 18:19:38 +08:00
|
|
|
id: 'app.toast.breakoutRoomEnded',
|
2017-10-19 03:24:26 +08:00
|
|
|
description: 'message when the breakout room is ended',
|
|
|
|
},
|
2017-10-19 18:45:07 +08:00
|
|
|
notificationRecordingStart: {
|
|
|
|
id: 'app.notification.recordingStart',
|
|
|
|
description: 'Notification for when the recording start',
|
|
|
|
},
|
|
|
|
notificationRecordingStop: {
|
|
|
|
id: 'app.notification.recordingStop',
|
|
|
|
description: 'Notification for when the recording stpop',
|
|
|
|
},
|
2017-10-19 03:24:26 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
class ToastContainer extends React.Component {
|
|
|
|
// we never want this component to update since will break Toastify
|
|
|
|
shouldComponentUpdate() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <Toastify {...this.props} />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
export default injectIntl(injectNotify(withTracker(({ notify, intl }) => {
|
2017-10-19 03:24:26 +08:00
|
|
|
Breakouts.find().observeChanges({
|
|
|
|
removed() {
|
2017-11-22 21:11:21 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.toastBreakoutRoomEnded), 'info', 'rooms');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-10-19 18:45:07 +08:00
|
|
|
const meetingId = Auth.meetingID;
|
|
|
|
|
|
|
|
Meetings.find({ meetingId }).observeChanges({
|
|
|
|
changed: (id, fields) => {
|
2017-10-21 03:00:34 +08:00
|
|
|
if (fields.recordProp && fields.recordProp.recording) {
|
2017-10-21 03:27:00 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.notificationRecordingStart), 'success', 'record');
|
2017-10-19 18:45:07 +08:00
|
|
|
}
|
|
|
|
|
2017-10-21 03:00:34 +08:00
|
|
|
if (fields.recordProp && !fields.recordProp.recording) {
|
2017-10-21 03:27:00 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.notificationRecordingStop), 'error', 'record');
|
2017-10-19 18:45:07 +08:00
|
|
|
}
|
2017-10-19 03:24:26 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
closeButton: (<Icon className={styles.close} iconName="close" />),
|
|
|
|
autoClose: 5000,
|
|
|
|
className: styles.container,
|
|
|
|
toastClassName: styles.toast,
|
|
|
|
bodyClassName: styles.body,
|
|
|
|
progressClassName: styles.progress,
|
|
|
|
newestOnTop: false,
|
|
|
|
hideProgressBar: false,
|
|
|
|
closeOnClick: true,
|
|
|
|
pauseOnHover: true,
|
|
|
|
};
|
2018-01-08 12:44:42 +08:00
|
|
|
})(ToastContainer)));
|