2019-02-27 01:40:01 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages } from 'react-intl';
|
2019-02-27 01:40:01 +08:00
|
|
|
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2023-03-20 21:08:35 +08:00
|
|
|
import ModalSimple from '/imports/ui/components/common/modal/simple/component';
|
2021-10-26 20:02:01 +08:00
|
|
|
import Styled from './styles';
|
2019-02-27 01:40:01 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2019-02-27 01:40:01 +08:00
|
|
|
responseDelay: PropTypes.number.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
activityCheckTitle: {
|
|
|
|
id: 'app.user.activityCheck',
|
|
|
|
description: 'Title for activity check modal',
|
|
|
|
},
|
|
|
|
activityCheckLabel: {
|
|
|
|
id: 'app.user.activityCheck.label',
|
|
|
|
description: 'Label for activity check modal',
|
|
|
|
},
|
|
|
|
activityCheckButton: {
|
|
|
|
id: 'app.user.activityCheck.check',
|
|
|
|
description: 'Check button for activity modal',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class ActivityCheck extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
const { responseDelay } = this.props;
|
|
|
|
|
|
|
|
this.state = ({
|
|
|
|
responseDelay,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.stopRemainingTime = this.stopRemainingTime.bind(this);
|
|
|
|
this.updateRemainingTime = this.updateRemainingTime.bind(this);
|
2019-03-12 20:28:11 +08:00
|
|
|
this.playAudioAlert = this.playAudioAlert.bind(this);
|
2019-02-27 01:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2019-03-12 20:28:11 +08:00
|
|
|
this.playAudioAlert();
|
2019-02-27 01:40:01 +08:00
|
|
|
this.interval = this.updateRemainingTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate() {
|
|
|
|
this.stopRemainingTime();
|
|
|
|
this.interval = this.updateRemainingTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this.stopRemainingTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateRemainingTime() {
|
|
|
|
const { responseDelay } = this.state;
|
|
|
|
|
|
|
|
return setInterval(() => {
|
2021-08-09 22:24:02 +08:00
|
|
|
if (responseDelay === 0) return;
|
2021-05-11 02:03:02 +08:00
|
|
|
|
2019-02-27 01:40:01 +08:00
|
|
|
const remainingTime = responseDelay - 1;
|
2020-08-03 20:44:21 +08:00
|
|
|
|
2019-02-27 01:40:01 +08:00
|
|
|
this.setState({
|
|
|
|
responseDelay: remainingTime,
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
stopRemainingTime() {
|
|
|
|
clearInterval(this.interval);
|
|
|
|
}
|
|
|
|
|
2019-03-12 20:28:11 +08:00
|
|
|
playAudioAlert() {
|
2024-08-03 02:10:39 +08:00
|
|
|
this.alert = new Audio(`${window.meetingClientSettings.public.app.cdn + window.meetingClientSettings.public.app.basename}/resources/sounds/notify.mp3`);
|
2021-05-04 21:24:30 +08:00
|
|
|
this.alert.addEventListener('ended', () => { this.alert.src = null; });
|
2019-03-12 20:28:11 +08:00
|
|
|
this.alert.play();
|
|
|
|
}
|
|
|
|
|
2019-02-27 01:40:01 +08:00
|
|
|
render() {
|
2024-04-25 22:53:56 +08:00
|
|
|
const { intl, userActivitySign } = this.props;
|
2019-02-27 01:40:01 +08:00
|
|
|
|
|
|
|
const { responseDelay } = this.state;
|
|
|
|
|
|
|
|
return (
|
2023-03-20 21:08:35 +08:00
|
|
|
<ModalSimple
|
2019-02-27 01:40:01 +08:00
|
|
|
hideBorder
|
2024-04-25 22:53:56 +08:00
|
|
|
onRequestClose={() => userActivitySign()}
|
2019-02-27 01:40:01 +08:00
|
|
|
shouldCloseOnOverlayClick={false}
|
|
|
|
shouldShowCloseButton={false}
|
2024-02-14 03:13:56 +08:00
|
|
|
priority="high"
|
|
|
|
isOpen
|
2019-02-27 01:40:01 +08:00
|
|
|
>
|
2021-10-26 20:02:01 +08:00
|
|
|
<Styled.ActivityModalContent>
|
2019-02-27 01:40:01 +08:00
|
|
|
<h1>{intl.formatMessage(intlMessages.activityCheckTitle)}</h1>
|
|
|
|
<p>{intl.formatMessage(intlMessages.activityCheckLabel, { 0: responseDelay })}</p>
|
|
|
|
<Button
|
|
|
|
color="primary"
|
2020-08-03 20:44:21 +08:00
|
|
|
disabled={responseDelay <= 0}
|
2019-02-27 01:40:01 +08:00
|
|
|
label={intl.formatMessage(intlMessages.activityCheckButton)}
|
2024-04-25 22:53:56 +08:00
|
|
|
onClick={() => userActivitySign()}
|
2019-02-27 01:40:01 +08:00
|
|
|
role="button"
|
|
|
|
size="lg"
|
|
|
|
/>
|
2021-10-26 20:02:01 +08:00
|
|
|
</Styled.ActivityModalContent>
|
2023-03-20 21:08:35 +08:00
|
|
|
</ModalSimple>
|
2019-02-27 01:40:01 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ActivityCheck.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default ActivityCheck;
|