2020-06-03 03:47:26 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-03-11 04:47:23 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2021-10-28 03:51:43 +08:00
|
|
|
import Styled from './styles';
|
2017-03-11 04:47:23 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
2022-10-14 21:27:23 +08:00
|
|
|
503: {
|
|
|
|
id: 'app.error.503',
|
|
|
|
},
|
2017-03-11 04:47:23 +08:00
|
|
|
500: {
|
|
|
|
id: 'app.error.500',
|
2020-02-07 04:47:28 +08:00
|
|
|
defaultMessage: 'Oops, something went wrong',
|
2017-03-11 04:47:23 +08:00
|
|
|
},
|
2019-04-27 01:52:18 +08:00
|
|
|
410: {
|
|
|
|
id: 'app.error.410',
|
|
|
|
},
|
2022-10-14 21:27:23 +08:00
|
|
|
409: {
|
|
|
|
id: 'app.error.409',
|
|
|
|
},
|
2020-10-08 03:50:17 +08:00
|
|
|
408: {
|
|
|
|
id: 'app.error.408',
|
|
|
|
},
|
2017-03-11 04:47:23 +08:00
|
|
|
404: {
|
|
|
|
id: 'app.error.404',
|
2017-04-15 07:26:34 +08:00
|
|
|
defaultMessage: 'Not found',
|
2017-03-11 04:47:23 +08:00
|
|
|
},
|
2019-04-27 01:14:37 +08:00
|
|
|
403: {
|
|
|
|
id: 'app.error.403',
|
|
|
|
},
|
2017-03-11 04:47:23 +08:00
|
|
|
401: {
|
2017-04-18 01:14:31 +08:00
|
|
|
id: 'app.error.401',
|
2017-03-11 04:47:23 +08:00
|
|
|
},
|
2019-01-09 02:38:26 +08:00
|
|
|
400: {
|
|
|
|
id: 'app.error.400',
|
|
|
|
},
|
2022-11-24 21:17:48 +08:00
|
|
|
meeting_ended: {
|
|
|
|
id: 'app.meeting.endedMessage',
|
|
|
|
},
|
2021-03-30 21:09:25 +08:00
|
|
|
user_logged_out_reason: {
|
|
|
|
id: 'app.error.userLoggedOut',
|
|
|
|
},
|
|
|
|
validate_token_failed_eject_reason: {
|
|
|
|
id: 'app.error.ejectedUser',
|
|
|
|
},
|
|
|
|
banned_user_rejoining_reason: {
|
|
|
|
id: 'app.error.userBanned',
|
|
|
|
},
|
2022-05-14 03:18:51 +08:00
|
|
|
joined_another_window_reason: {
|
|
|
|
id: 'app.error.joinedAnotherWindow',
|
|
|
|
},
|
2022-08-16 01:59:58 +08:00
|
|
|
user_inactivity_eject_reason: {
|
|
|
|
id: 'app.meeting.logout.userInactivityEjectReason',
|
|
|
|
},
|
2022-09-23 01:22:58 +08:00
|
|
|
user_requested_eject_reason: {
|
|
|
|
id: 'app.meeting.logout.ejectedFromMeeting',
|
|
|
|
},
|
2022-10-27 00:19:16 +08:00
|
|
|
max_participants_reason: {
|
|
|
|
id: 'app.meeting.logout.maxParticipantsReached',
|
|
|
|
},
|
2022-11-24 21:17:48 +08:00
|
|
|
guest_deny: {
|
|
|
|
id: 'app.guest.guestDeny',
|
|
|
|
},
|
2022-09-23 01:22:58 +08:00
|
|
|
duplicate_user_in_meeting_eject_reason: {
|
|
|
|
id: 'app.meeting.logout.duplicateUserEjectReason',
|
|
|
|
},
|
|
|
|
not_enough_permission_eject_reason: {
|
|
|
|
id: 'app.meeting.logout.permissionEjectReason',
|
|
|
|
},
|
2022-10-14 21:27:23 +08:00
|
|
|
able_to_rejoin_user_disconnected_reason: {
|
|
|
|
id: 'app.error.disconnected.rejoin',
|
|
|
|
},
|
2017-03-11 04:47:23 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
code: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.number,
|
|
|
|
]),
|
2024-03-07 01:28:18 +08:00
|
|
|
error: PropTypes.object,
|
|
|
|
errorInfo: PropTypes.object,
|
2017-03-11 04:47:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
2022-10-18 00:35:23 +08:00
|
|
|
code: '500',
|
2023-12-08 02:37:04 +08:00
|
|
|
callback: () => {},
|
|
|
|
endedReason: null,
|
2024-03-07 01:28:18 +08:00
|
|
|
error: {},
|
|
|
|
errorInfo: null,
|
2017-03-11 04:47:23 +08:00
|
|
|
};
|
|
|
|
|
2020-06-03 03:47:26 +08:00
|
|
|
class ErrorScreen extends PureComponent {
|
2018-11-05 23:48:57 +08:00
|
|
|
componentDidMount() {
|
2023-12-08 02:37:04 +08:00
|
|
|
const { code, callback, endedReason } = this.props;
|
2024-03-07 01:28:18 +08:00
|
|
|
// stop audio
|
|
|
|
document.querySelector('audio').pause();
|
|
|
|
navigator
|
|
|
|
.mediaDevices
|
|
|
|
.getUserMedia({ audio: true, video: true })
|
|
|
|
.then((m) => m.getTracks().forEach((t) => t.stop()));
|
2024-05-02 01:11:04 +08:00
|
|
|
window.dispatchEvent(new Event('StopAudioTracks'));
|
2024-06-15 03:54:31 +08:00
|
|
|
callback(endedReason, () => {});
|
2024-03-07 01:28:18 +08:00
|
|
|
console.error({ logCode: 'startup_client_usercouldnotlogin_error' }, `User could not log in HTML5, hit ${code}`);
|
2018-11-05 23:48:57 +08:00
|
|
|
}
|
|
|
|
|
2017-03-11 04:47:23 +08:00
|
|
|
render() {
|
2017-12-12 21:08:43 +08:00
|
|
|
const {
|
2018-10-04 00:14:10 +08:00
|
|
|
intl,
|
|
|
|
code,
|
|
|
|
children,
|
2024-03-07 01:28:18 +08:00
|
|
|
error,
|
|
|
|
errorInfo,
|
2017-12-12 21:08:43 +08:00
|
|
|
} = this.props;
|
2024-03-07 01:28:18 +08:00
|
|
|
let formatedMessage = 'Oops, something went wrong';
|
2024-06-06 21:50:03 +08:00
|
|
|
let errorMessageDescription = Session.getItem('errorMessageDescription');
|
2024-03-07 01:28:18 +08:00
|
|
|
if (intl) {
|
|
|
|
formatedMessage = intl.formatMessage(intlMessages[defaultProps.code]);
|
2017-03-11 04:47:23 +08:00
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
if (code in intlMessages) {
|
|
|
|
formatedMessage = intl.formatMessage(intlMessages[code]);
|
|
|
|
}
|
2017-03-11 04:47:23 +08:00
|
|
|
|
2024-06-06 21:50:03 +08:00
|
|
|
errorMessageDescription = Session.getItem('errorMessageDescription');
|
2017-03-11 04:47:23 +08:00
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
if (errorMessageDescription in intlMessages) {
|
|
|
|
errorMessageDescription = intl.formatMessage(intlMessages[errorMessageDescription]);
|
|
|
|
}
|
|
|
|
}
|
2021-03-30 21:09:25 +08:00
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
if (error) {
|
|
|
|
errorMessageDescription = error.message;
|
2021-03-30 21:09:25 +08:00
|
|
|
}
|
|
|
|
|
2017-03-11 04:47:23 +08:00
|
|
|
return (
|
2021-10-28 03:51:43 +08:00
|
|
|
<Styled.Background>
|
|
|
|
<Styled.Message data-test="errorScreenMessage">
|
2017-03-11 04:47:23 +08:00
|
|
|
{formatedMessage}
|
2021-10-28 03:51:43 +08:00
|
|
|
</Styled.Message>
|
2019-01-08 00:26:23 +08:00
|
|
|
{
|
2022-09-23 01:22:58 +08:00
|
|
|
!errorMessageDescription
|
|
|
|
|| formatedMessage === errorMessageDescription
|
|
|
|
|| (
|
2021-10-28 03:51:43 +08:00
|
|
|
<Styled.SessionMessage>
|
2021-03-30 21:09:25 +08:00
|
|
|
{errorMessageDescription}
|
2021-10-28 03:51:43 +08:00
|
|
|
</Styled.SessionMessage>
|
|
|
|
)
|
2019-01-08 00:26:23 +08:00
|
|
|
}
|
2024-03-07 01:28:18 +08:00
|
|
|
{
|
|
|
|
errorInfo
|
|
|
|
? (
|
|
|
|
<textarea
|
|
|
|
rows="5"
|
|
|
|
cols="33"
|
|
|
|
disabled
|
|
|
|
>
|
|
|
|
{JSON.stringify(errorInfo)}
|
|
|
|
</textarea>
|
|
|
|
)
|
|
|
|
: null
|
|
|
|
}
|
2021-10-28 03:51:43 +08:00
|
|
|
<Styled.Separator />
|
|
|
|
<Styled.CodeError>
|
2020-06-19 20:49:07 +08:00
|
|
|
{code}
|
2021-10-28 03:51:43 +08:00
|
|
|
</Styled.CodeError>
|
2018-12-06 01:42:31 +08:00
|
|
|
<div>
|
2017-03-11 04:47:23 +08:00
|
|
|
{children}
|
2017-04-29 04:16:07 +08:00
|
|
|
</div>
|
2021-10-28 03:51:43 +08:00
|
|
|
</Styled.Background>
|
2017-03-11 04:47:23 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-04 00:14:10 +08:00
|
|
|
export default injectIntl(ErrorScreen);
|
2017-03-11 04:47:23 +08:00
|
|
|
|
2024-03-07 01:28:18 +08:00
|
|
|
export { ErrorScreen };
|
|
|
|
|
2017-03-11 04:47:23 +08:00
|
|
|
ErrorScreen.propTypes = propTypes;
|
|
|
|
ErrorScreen.defaultProps = defaultProps;
|