2019-03-19 22:15:44 +08:00
|
|
|
import { Component } from 'react';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import { notify } from '/imports/ui/services/notification';
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
disableCam: {
|
|
|
|
id: 'app.userList.userOptions.disableCam',
|
|
|
|
description: 'label to disable cam notification',
|
|
|
|
},
|
|
|
|
disableMic: {
|
|
|
|
id: 'app.userList.userOptions.disableMic',
|
|
|
|
description: 'label to disable mic notification',
|
|
|
|
},
|
2019-05-09 23:58:08 +08:00
|
|
|
disablePrivateChat: {
|
2019-03-19 22:15:44 +08:00
|
|
|
id: 'app.userList.userOptions.disablePrivChat',
|
|
|
|
description: 'label to disable private chat notification',
|
|
|
|
},
|
2019-05-09 23:58:08 +08:00
|
|
|
disablePublicChat: {
|
2019-03-19 22:15:44 +08:00
|
|
|
id: 'app.userList.userOptions.disablePubChat',
|
|
|
|
description: 'label to disable private chat notification',
|
|
|
|
},
|
2019-03-30 02:22:52 +08:00
|
|
|
disableNote: {
|
|
|
|
id: 'app.userList.userOptions.disableNote',
|
|
|
|
description: 'label to disable note notification',
|
|
|
|
},
|
2019-03-19 22:15:44 +08:00
|
|
|
onlyModeratorWebcam: {
|
|
|
|
id: 'app.userList.userOptions.webcamsOnlyForModerator',
|
|
|
|
description: 'label to disable all webcams except for the moderators cam',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class LockViewersNotifyComponent extends Component {
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
const {
|
|
|
|
lockSettings,
|
|
|
|
intl,
|
|
|
|
webcamsOnlyForModerator,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
lockSettings: prevLockSettings,
|
|
|
|
webcamsOnlyForModerator: prevWebcamsOnlyForModerator,
|
|
|
|
} = prevProps;
|
|
|
|
|
|
|
|
if (!_.isEqual(lockSettings, prevLockSettings)) {
|
2019-04-05 22:07:29 +08:00
|
|
|
const rejectedKeys = ['setBy', 'lockedLayout'];
|
2019-03-19 22:15:44 +08:00
|
|
|
const filteredSettings = Object.keys(lockSettings)
|
|
|
|
.filter(key => prevLockSettings[key] !== lockSettings[key]
|
|
|
|
&& lockSettings[key]
|
2019-04-05 22:07:29 +08:00
|
|
|
&& !rejectedKeys.includes(key));
|
2019-03-19 22:15:44 +08:00
|
|
|
filteredSettings.forEach((key) => {
|
|
|
|
notify(intl.formatMessage(intlMessages[key]), 'info', 'lock');
|
|
|
|
});
|
|
|
|
}
|
2019-03-29 21:45:53 +08:00
|
|
|
if (webcamsOnlyForModerator && !prevWebcamsOnlyForModerator) {
|
2019-03-19 22:15:44 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.onlyModeratorWebcam), 'info', 'lock');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(LockViewersNotifyComponent);
|