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

78 lines
1.6 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
2017-10-27 01:14:50 +08:00
import injectNotify from '/imports/ui/components/toast/inject-notify/component';
2018-10-17 01:48:27 +08:00
import { Session } from 'meteor/session';
const propTypes = {
notify: PropTypes.func.isRequired,
onOpen: PropTypes.func.isRequired,
2018-10-25 23:20:37 +08:00
chatId: PropTypes.string.isRequired,
2019-01-14 21:23:35 +08:00
title: PropTypes.node.isRequired,
2018-10-25 23:20:37 +08:00
content: PropTypes.node.isRequired,
2019-01-14 21:23:35 +08:00
alertDuration: PropTypes.number.isRequired,
};
2017-10-27 01:14:50 +08:00
class ChatPushAlert extends PureComponent {
2019-01-14 21:23:35 +08:00
static link(title, chatId) {
2019-01-22 19:42:03 +08:00
let chat = chatId;
if (chat === 'MAIN-PUBLIC-GROUP-CHAT') {
chat = 'public';
}
2018-10-17 01:48:27 +08:00
return (
<div
2019-01-14 21:23:35 +08:00
key={chatId}
2018-10-17 01:48:27 +08:00
role="button"
2019-01-14 21:23:35 +08:00
aria-label={title}
2018-10-25 23:20:37 +08:00
tabIndex={0}
2018-10-17 01:48:27 +08:00
onClick={() => {
2018-12-18 23:15:51 +08:00
Session.set('openPanel', 'chat');
2019-01-22 19:42:03 +08:00
Session.set('idChatOpen', chat);
window.dispatchEvent(new Event('panelChanged'));
2018-12-18 23:15:51 +08:00
}}
2019-01-22 19:42:03 +08:00
onKeyPress={() => null}
2018-10-17 01:48:27 +08:00
>
2019-01-14 21:23:35 +08:00
{title}
2018-10-17 01:48:27 +08:00
</div>
);
}
2017-10-27 01:14:50 +08:00
constructor(props) {
super(props);
2019-01-14 21:23:35 +08:00
this.showNotify = this.showNotify.bind(this);
2017-10-27 01:14:50 +08:00
this.componentDidMount = this.showNotify;
this.componentDidUpdate = this.showNotify;
}
showNotify() {
const {
notify,
onOpen,
chatId,
2019-01-14 21:23:35 +08:00
title,
content,
2019-01-14 21:23:35 +08:00
alertDuration,
2017-10-27 01:14:50 +08:00
} = this.props;
2018-06-15 22:37:57 +08:00
return notify(
2019-01-14 21:23:35 +08:00
ChatPushAlert.link(title, chatId),
2018-06-15 22:37:57 +08:00
'info',
'chat',
2019-01-14 21:23:35 +08:00
{ onOpen, autoClose: alertDuration },
2018-08-15 10:35:58 +08:00
ChatPushAlert.link(content, chatId),
2018-06-15 22:37:57 +08:00
true,
);
2017-10-27 01:14:50 +08:00
}
render() {
return null;
}
}
2018-08-15 10:35:58 +08:00
ChatPushAlert.propTypes = propTypes;
2017-10-27 01:14:50 +08:00
2018-08-15 10:35:58 +08:00
export default injectNotify(ChatPushAlert);