Merge pull request #7945 from bigbluebutton/revert-7823-join-HOC
Revert "Implement HOC to handle errors"
This commit is contained in:
commit
e77647b7c5
@ -7,7 +7,6 @@ import Base from '/imports/startup/client/base';
|
|||||||
import JoinHandler from '/imports/ui/components/join-handler/component';
|
import JoinHandler from '/imports/ui/components/join-handler/component';
|
||||||
import AuthenticatedHandler from '/imports/ui/components/authenticated-handler/component';
|
import AuthenticatedHandler from '/imports/ui/components/authenticated-handler/component';
|
||||||
import Subscriptions from '/imports/ui/components/subscriptions/component';
|
import Subscriptions from '/imports/ui/components/subscriptions/component';
|
||||||
import JoinLoading from '/imports/ui/components/join-loading/component';
|
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
// Logs all uncaught exceptions to the client logger
|
// Logs all uncaught exceptions to the client logger
|
||||||
@ -34,15 +33,13 @@ Meteor.startup(() => {
|
|||||||
|
|
||||||
// TODO make this a Promise
|
// TODO make this a Promise
|
||||||
render(
|
render(
|
||||||
<JoinLoading>
|
<JoinHandler>
|
||||||
<JoinHandler>
|
<AuthenticatedHandler>
|
||||||
<AuthenticatedHandler>
|
<Subscriptions>
|
||||||
<Subscriptions>
|
<Base />
|
||||||
<Base />
|
</Subscriptions>
|
||||||
</Subscriptions>
|
</AuthenticatedHandler>
|
||||||
</AuthenticatedHandler>
|
</JoinHandler>,
|
||||||
</JoinHandler>
|
|
||||||
</JoinLoading>,
|
|
||||||
document.getElementById('app'),
|
document.getElementById('app'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,9 @@ import { withTracker } from 'meteor/react-meteor-data';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Auth from '/imports/ui/services/auth';
|
import Auth from '/imports/ui/services/auth';
|
||||||
import AppContainer from '/imports/ui/components/app/container';
|
import AppContainer from '/imports/ui/components/app/container';
|
||||||
|
import ErrorScreen from '/imports/ui/components/error-screen/component';
|
||||||
import MeetingEnded from '/imports/ui/components/meeting-ended/component';
|
import MeetingEnded from '/imports/ui/components/meeting-ended/component';
|
||||||
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
||||||
import Settings from '/imports/ui/services/settings';
|
import Settings from '/imports/ui/services/settings';
|
||||||
import AudioManager from '/imports/ui/services/audio-manager';
|
import AudioManager from '/imports/ui/services/audio-manager';
|
||||||
import logger from '/imports/startup/client/logger';
|
import logger from '/imports/startup/client/logger';
|
||||||
@ -16,7 +18,6 @@ import Breakouts from '/imports/api/breakouts';
|
|||||||
import AudioService from '/imports/ui/components/audio/service';
|
import AudioService from '/imports/ui/components/audio/service';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { notify } from '/imports/ui/services/notification';
|
import { notify } from '/imports/ui/services/notification';
|
||||||
import { withJoinLoadingConsumer } from '/imports/ui/components/join-loading/context/context';
|
|
||||||
|
|
||||||
const HTML = document.getElementsByTagName('html')[0];
|
const HTML = document.getElementsByTagName('html')[0];
|
||||||
|
|
||||||
@ -86,29 +87,12 @@ class Base extends Component {
|
|||||||
ejected,
|
ejected,
|
||||||
isMeteorConnected,
|
isMeteorConnected,
|
||||||
subscriptionsReady,
|
subscriptionsReady,
|
||||||
codeError,
|
|
||||||
meetingHasEnded,
|
|
||||||
dispatch,
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
loading,
|
loading,
|
||||||
meetingExisted,
|
meetingExisted,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
if (codeError && !meetingHasEnded) {
|
|
||||||
// 680 is set for the codeError when the user requests a logout
|
|
||||||
if (codeError !== '680') {
|
|
||||||
logger.error({ logCode: 'startup_client_usercouldnotlogin_error' }, `User could not log in HTML5, hit ${codeError}`);
|
|
||||||
}
|
|
||||||
Session.set('codeError', codeError);
|
|
||||||
return dispatch('hasError');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(loading || !subscriptionsReady)
|
|
||||||
&& !meetingHasEnded && meetingExist) {
|
|
||||||
dispatch('hideLoading');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!prevProps.subscriptionsReady && subscriptionsReady) {
|
if (!prevProps.subscriptionsReady && subscriptionsReady) {
|
||||||
logger.info({ logCode: 'startup_client_subscriptions_ready' }, 'Subscriptions are ready');
|
logger.info({ logCode: 'startup_client_subscriptions_ready' }, 'Subscriptions are ready');
|
||||||
}
|
}
|
||||||
@ -168,14 +152,21 @@ class Base extends Component {
|
|||||||
renderByState() {
|
renderByState() {
|
||||||
const { updateLoadingState } = this;
|
const { updateLoadingState } = this;
|
||||||
const stateControls = { updateLoadingState };
|
const stateControls = { updateLoadingState };
|
||||||
|
const { loading } = this.state;
|
||||||
const codeError = Session.get('codeError');
|
const codeError = Session.get('codeError');
|
||||||
const {
|
const {
|
||||||
ejected,
|
ejected,
|
||||||
|
meetingExist,
|
||||||
meetingHasEnded,
|
meetingHasEnded,
|
||||||
meetingIsBreakout,
|
meetingIsBreakout,
|
||||||
|
subscriptionsReady,
|
||||||
User,
|
User,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
if ((loading || !subscriptionsReady) && !meetingHasEnded && meetingExist) {
|
||||||
|
return (<LoadingScreen>{loading}</LoadingScreen>);
|
||||||
|
}
|
||||||
|
|
||||||
if (ejected && ejected.ejectedReason) {
|
if (ejected && ejected.ejectedReason) {
|
||||||
const { ejectedReason } = ejected;
|
const { ejectedReason } = ejected;
|
||||||
AudioManager.exitAudio();
|
AudioManager.exitAudio();
|
||||||
@ -188,6 +179,14 @@ class Base extends Component {
|
|||||||
AudioManager.exitAudio();
|
AudioManager.exitAudio();
|
||||||
return (<MeetingEnded code={codeError} />);
|
return (<MeetingEnded code={codeError} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (codeError && !meetingHasEnded) {
|
||||||
|
// 680 is set for the codeError when the user requests a logout
|
||||||
|
if (codeError !== '680') {
|
||||||
|
logger.error({ logCode: 'startup_client_usercouldnotlogin_error' }, `User could not log in HTML5, hit ${codeError}`);
|
||||||
|
}
|
||||||
|
return (<ErrorScreen code={codeError} />);
|
||||||
|
}
|
||||||
// this.props.annotationsHandler.stop();
|
// this.props.annotationsHandler.stop();
|
||||||
return (<AppContainer {...this.props} baseControls={stateControls} />);
|
return (<AppContainer {...this.props} baseControls={stateControls} />);
|
||||||
}
|
}
|
||||||
@ -197,11 +196,15 @@ class Base extends Component {
|
|||||||
const { locale, meetingExist } = this.props;
|
const { locale, meetingExist } = this.props;
|
||||||
const stateControls = { updateLoadingState };
|
const stateControls = { updateLoadingState };
|
||||||
const { meetingExisted } = this.state;
|
const { meetingExisted } = this.state;
|
||||||
if ((!meetingExisted && !meetingExist && Auth.loggedIn)) return null;
|
|
||||||
return (
|
return (
|
||||||
<IntlStartup locale={locale} baseControls={stateControls}>
|
(!meetingExisted && !meetingExist && Auth.loggedIn)
|
||||||
{this.renderByState()}
|
? <LoadingScreen />
|
||||||
</IntlStartup>
|
: (
|
||||||
|
<IntlStartup locale={locale} baseControls={stateControls}>
|
||||||
|
{this.renderByState()}
|
||||||
|
</IntlStartup>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,4 +316,4 @@ const BaseContainer = withTracker(() => {
|
|||||||
};
|
};
|
||||||
})(Base);
|
})(Base);
|
||||||
|
|
||||||
export default withJoinLoadingConsumer(BaseContainer);
|
export default BaseContainer;
|
||||||
|
@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
||||||
import Settings from '/imports/ui/services/settings';
|
import Settings from '/imports/ui/services/settings';
|
||||||
import { withJoinLoadingConsumer } from '/imports/ui/components/join-loading/context/context';
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
||||||
|
|
||||||
// currently supported locales.
|
// currently supported locales.
|
||||||
import ar from 'react-intl/locale-data/ar';
|
import ar from 'react-intl/locale-data/ar';
|
||||||
@ -106,7 +106,7 @@ class IntlStartup extends Component {
|
|||||||
|
|
||||||
fetchLocalizedMessages(locale) {
|
fetchLocalizedMessages(locale) {
|
||||||
const url = `/html5client/locale?locale=${locale}`;
|
const url = `/html5client/locale?locale=${locale}`;
|
||||||
const { dispatch } = this.props;
|
|
||||||
this.setState({ fetching: true }, () => {
|
this.setState({ fetching: true }, () => {
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -120,7 +120,6 @@ class IntlStartup extends Component {
|
|||||||
const dasherizedLocale = normalizedLocale.replace('_', '-');
|
const dasherizedLocale = normalizedLocale.replace('_', '-');
|
||||||
this.setState({ messages, fetching: false, normalizedLocale: dasherizedLocale }, () => {
|
this.setState({ messages, fetching: false, normalizedLocale: dasherizedLocale }, () => {
|
||||||
this.saveLocale(dasherizedLocale);
|
this.saveLocale(dasherizedLocale);
|
||||||
dispatch('hideLoading');
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -147,7 +146,7 @@ class IntlStartup extends Component {
|
|||||||
const { fetching, normalizedLocale, messages } = this.state;
|
const { fetching, normalizedLocale, messages } = this.state;
|
||||||
const { children } = this.props;
|
const { children } = this.props;
|
||||||
|
|
||||||
return !fetching && (
|
return fetching ? <LoadingScreen /> : (
|
||||||
<IntlProvider locale={normalizedLocale} messages={messages}>
|
<IntlProvider locale={normalizedLocale} messages={messages}>
|
||||||
{children}
|
{children}
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
@ -155,7 +154,7 @@ class IntlStartup extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withJoinLoadingConsumer(IntlStartup);
|
export default IntlStartup;
|
||||||
|
|
||||||
IntlStartup.propTypes = propTypes;
|
IntlStartup.propTypes = propTypes;
|
||||||
IntlStartup.defaultProps = defaultProps;
|
IntlStartup.defaultProps = defaultProps;
|
||||||
|
@ -2,13 +2,18 @@ import React, { Component } from 'react';
|
|||||||
import { Session } from 'meteor/session';
|
import { Session } from 'meteor/session';
|
||||||
import logger from '/imports/startup/client/logger';
|
import logger from '/imports/startup/client/logger';
|
||||||
import Auth from '/imports/ui/services/auth';
|
import Auth from '/imports/ui/services/auth';
|
||||||
import { withJoinLoadingConsumer } from '/imports/ui/components/join-loading/context/context';
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
||||||
|
|
||||||
const STATUS_CONNECTING = 'connecting';
|
const STATUS_CONNECTING = 'connecting';
|
||||||
const CHAT_CONFIG = Meteor.settings.public.chat;
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
||||||
const PUBLIC_CHAT_ID = CHAT_CONFIG.public_id;
|
const PUBLIC_CHAT_ID = CHAT_CONFIG.public_id;
|
||||||
|
|
||||||
class AuthenticatedHandler extends Component {
|
class AuthenticatedHandler extends Component {
|
||||||
|
static setError(codeError) {
|
||||||
|
Session.set('hasError', true);
|
||||||
|
if (codeError) Session.set('codeError', codeError);
|
||||||
|
}
|
||||||
|
|
||||||
static shouldAuthenticate(status, lastStatus) {
|
static shouldAuthenticate(status, lastStatus) {
|
||||||
return lastStatus != null && lastStatus === STATUS_CONNECTING && status.connected;
|
return lastStatus != null && lastStatus === STATUS_CONNECTING && status.connected;
|
||||||
}
|
}
|
||||||
@ -30,32 +35,7 @@ class AuthenticatedHandler extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
static async authenticatedRouteHandler(callback) {
|
||||||
super(props);
|
|
||||||
this.setError = this.setError.bind(this);
|
|
||||||
this.authenticatedRouteHandler = this.authenticatedRouteHandler.bind(this);
|
|
||||||
this.state = {
|
|
||||||
authenticated: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if (Session.get('codeError')) {
|
|
||||||
return this.setError(Session.get('codeError'));
|
|
||||||
}
|
|
||||||
return this.authenticatedRouteHandler((value, error) => {
|
|
||||||
if (error) return this.setError(error);
|
|
||||||
return this.setState({ authenticated: true });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(codeError) {
|
|
||||||
const { dispatch } = this.props;
|
|
||||||
dispatch('hasError');
|
|
||||||
if (codeError) Session.set('codeError', codeError);
|
|
||||||
}
|
|
||||||
|
|
||||||
async authenticatedRouteHandler(callback) {
|
|
||||||
if (Auth.loggedIn) {
|
if (Auth.loggedIn) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -63,7 +43,6 @@ class AuthenticatedHandler extends Component {
|
|||||||
AuthenticatedHandler.addReconnectObservable();
|
AuthenticatedHandler.addReconnectObservable();
|
||||||
|
|
||||||
const setReason = (reason) => {
|
const setReason = (reason) => {
|
||||||
this.setError(reason.error);
|
|
||||||
logger.error({
|
logger.error({
|
||||||
logCode: 'authenticatedhandlercomponent_setreason',
|
logCode: 'authenticatedhandlercomponent_setreason',
|
||||||
extraInfo: { reason },
|
extraInfo: { reason },
|
||||||
@ -81,6 +60,21 @@ class AuthenticatedHandler extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
authenticated: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (Session.get('codeError')) return this.changeState(true);
|
||||||
|
AuthenticatedHandler.authenticatedRouteHandler((value, error) => {
|
||||||
|
if (error) AuthenticatedHandler.setError(error);
|
||||||
|
this.setState({ authenticated: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
children,
|
children,
|
||||||
@ -95,9 +89,11 @@ class AuthenticatedHandler extends Component {
|
|||||||
Session.set('isPollOpen', false);
|
Session.set('isPollOpen', false);
|
||||||
Session.set('breakoutRoomIsOpen', false);
|
Session.set('breakoutRoomIsOpen', false);
|
||||||
|
|
||||||
return authenticated && children;
|
return authenticated
|
||||||
|
? children
|
||||||
|
: (<LoadingScreen />);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default withJoinLoadingConsumer(AuthenticatedHandler);
|
export default AuthenticatedHandler;
|
||||||
|
@ -57,16 +57,16 @@ class ErrorScreen extends React.PureComponent {
|
|||||||
children,
|
children,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const codeError = Session.get('codeError') || code;
|
|
||||||
let formatedMessage = intl.formatMessage(intlMessages[defaultProps.code]);
|
let formatedMessage = intl.formatMessage(intlMessages[defaultProps.code]);
|
||||||
|
|
||||||
if (codeError in intlMessages) {
|
if (code in intlMessages) {
|
||||||
formatedMessage = intl.formatMessage(intlMessages[codeError]);
|
formatedMessage = intl.formatMessage(intlMessages[code]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.background}>
|
<div className={styles.background}>
|
||||||
<h1 className={styles.codeError}>
|
<h1 className={styles.codeError}>
|
||||||
{codeError}
|
{code}
|
||||||
</h1>
|
</h1>
|
||||||
<h1 className={styles.message}>
|
<h1 className={styles.message}>
|
||||||
{formatedMessage}
|
{formatedMessage}
|
||||||
|
@ -6,7 +6,7 @@ import { setCustomLogoUrl } from '/imports/ui/components/user-list/service';
|
|||||||
import { makeCall } from '/imports/ui/services/api';
|
import { makeCall } from '/imports/ui/services/api';
|
||||||
import deviceInfo from '/imports/utils/deviceInfo';
|
import deviceInfo from '/imports/utils/deviceInfo';
|
||||||
import logger from '/imports/startup/client/logger';
|
import logger from '/imports/startup/client/logger';
|
||||||
import { withJoinLoadingConsumer } from '/imports/ui/components/join-loading/context/context';
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
children: PropTypes.element.isRequired,
|
children: PropTypes.element.isRequired,
|
||||||
@ -17,10 +17,14 @@ const { showParticipantsOnLogin } = APP_CONFIG;
|
|||||||
const CHAT_ENABLED = Meteor.settings.public.chat.enabled;
|
const CHAT_ENABLED = Meteor.settings.public.chat.enabled;
|
||||||
|
|
||||||
class JoinHandler extends Component {
|
class JoinHandler extends Component {
|
||||||
|
static setError(codeError) {
|
||||||
|
Session.set('hasError', true);
|
||||||
|
if (codeError) Session.set('codeError', codeError);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.fetchToken = this.fetchToken.bind(this);
|
this.fetchToken = this.fetchToken.bind(this);
|
||||||
this.setError = this.setError.bind(this);
|
|
||||||
this.numFetchTokenRetries = 0;
|
this.numFetchTokenRetries = 0;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@ -37,12 +41,6 @@ class JoinHandler extends Component {
|
|||||||
this._isMounted = false;
|
this._isMounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setError(codeError) {
|
|
||||||
const { dispatch } = this.props;
|
|
||||||
if (codeError) Session.set('codeError', codeError);
|
|
||||||
dispatch('hasError');
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchToken() {
|
async fetchToken() {
|
||||||
if (!this._isMounted) return;
|
if (!this._isMounted) return;
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ class JoinHandler extends Component {
|
|||||||
const sessionToken = urlParams.get('sessionToken');
|
const sessionToken = urlParams.get('sessionToken');
|
||||||
|
|
||||||
if (!sessionToken) {
|
if (!sessionToken) {
|
||||||
this.setError('400');
|
JoinHandler.setError('400');
|
||||||
Session.set('errorMessageDescription', 'Session token was not provided');
|
Session.set('errorMessageDescription', 'Session token was not provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +141,7 @@ class JoinHandler extends Component {
|
|||||||
const { response } = parseToJson;
|
const { response } = parseToJson;
|
||||||
|
|
||||||
setLogoutURL(response);
|
setLogoutURL(response);
|
||||||
|
|
||||||
if (response.returncode !== 'FAILED') {
|
if (response.returncode !== 'FAILED') {
|
||||||
await setAuth(response);
|
await setAuth(response);
|
||||||
|
|
||||||
@ -168,11 +167,9 @@ class JoinHandler extends Component {
|
|||||||
response,
|
response,
|
||||||
},
|
},
|
||||||
}, 'User successfully went through main.joinRouteHandler');
|
}, 'User successfully went through main.joinRouteHandler');
|
||||||
this.setState({ joined: true });
|
|
||||||
} else {
|
} else {
|
||||||
const e = new Error(response.message);
|
const e = new Error(response.message);
|
||||||
if (!Session.get('codeError')) Session.set('errorMessageDescription', response.message);
|
if (!Session.get('codeError')) Session.set('errorMessageDescription', response.message);
|
||||||
this.setError(401);
|
|
||||||
logger.error({
|
logger.error({
|
||||||
logCode: 'joinhandler_component_joinroutehandler_error',
|
logCode: 'joinhandler_component_joinroutehandler_error',
|
||||||
extraInfo: {
|
extraInfo: {
|
||||||
@ -181,15 +178,18 @@ class JoinHandler extends Component {
|
|||||||
},
|
},
|
||||||
}, 'User faced an error on main.joinRouteHandler.');
|
}, 'User faced an error on main.joinRouteHandler.');
|
||||||
}
|
}
|
||||||
|
this.setState({ joined: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children } = this.props;
|
const { children } = this.props;
|
||||||
const { joined } = this.state;
|
const { joined } = this.state;
|
||||||
return joined && children;
|
return joined
|
||||||
|
? children
|
||||||
|
: (<LoadingScreen />);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withJoinLoadingConsumer(JoinHandler);
|
export default JoinHandler;
|
||||||
|
|
||||||
JoinHandler.propTypes = propTypes;
|
JoinHandler.propTypes = propTypes;
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
import React, { Fragment } from 'react';
|
|
||||||
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
|
||||||
import ErrorScreen from '/imports/ui/components/error-screen/component';
|
|
||||||
import { withJoinLoadingContext } from './context/context';
|
|
||||||
import IntlProvider from '/imports/startup/client/intl';
|
|
||||||
import Settings from '/imports/ui/services/settings';
|
|
||||||
|
|
||||||
const JoinLoadComponent = (props) => {
|
|
||||||
const { children, showLoading, hasError } = props;
|
|
||||||
const { locale } = Settings.application;
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
{(showLoading && !hasError) && (<LoadingScreen />)}
|
|
||||||
{hasError ? (
|
|
||||||
<IntlProvider locale={locale}>
|
|
||||||
<ErrorScreen />
|
|
||||||
</IntlProvider>
|
|
||||||
) : children}
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withJoinLoadingContext(JoinLoadComponent);
|
|
@ -1,64 +0,0 @@
|
|||||||
import React, { useReducer, createContext } from 'react';
|
|
||||||
|
|
||||||
function reducer(state, action) {
|
|
||||||
switch (action) {
|
|
||||||
case 'showLoading':
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
showLoading: true,
|
|
||||||
};
|
|
||||||
case 'hideLoading':
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
showLoading: false,
|
|
||||||
};
|
|
||||||
case 'hasError':
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
hasError: true,
|
|
||||||
};
|
|
||||||
default:
|
|
||||||
throw new Error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const JoinLoadingContext = createContext({});
|
|
||||||
const initialState = {
|
|
||||||
showLoading: true,
|
|
||||||
hasError: false,
|
|
||||||
};
|
|
||||||
const JoinLoading = Component => (props) => {
|
|
||||||
const [state, dispatch] = useReducer(reducer, initialState);
|
|
||||||
const contextValue = {
|
|
||||||
...props,
|
|
||||||
...state,
|
|
||||||
dispatch,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<JoinLoadingContext.Provider value={contextValue}>
|
|
||||||
<Component />
|
|
||||||
</JoinLoadingContext.Provider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const joinLoadingContextConsumer = Component => props => (
|
|
||||||
<JoinLoadingContext.Consumer>
|
|
||||||
{ contexts => <Component {...contexts} {...props} />}
|
|
||||||
</JoinLoadingContext.Consumer>
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
const withJoinLoadingConsumer = Component => joinLoadingContextConsumer(Component);
|
|
||||||
|
|
||||||
const withJoinLoadingContext = Component => JoinLoading(withJoinLoadingConsumer(Component));
|
|
||||||
|
|
||||||
export {
|
|
||||||
withJoinLoadingContext,
|
|
||||||
withJoinLoadingConsumer,
|
|
||||||
joinLoadingContextConsumer,
|
|
||||||
JoinLoading,
|
|
||||||
reducer,
|
|
||||||
initialState,
|
|
||||||
JoinLoadingContext,
|
|
||||||
};
|
|
@ -11,18 +11,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.background {
|
.background {
|
||||||
|
position: fixed;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
position: fixed;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: var(--loader-bg);
|
background-color: var(--loader-bg);
|
||||||
z-index: 99999;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
|
@ -8,7 +8,6 @@ import Annotations from '/imports/api/annotations';
|
|||||||
import AnnotationsTextService from '/imports/ui/components/whiteboard/annotations/text/service';
|
import AnnotationsTextService from '/imports/ui/components/whiteboard/annotations/text/service';
|
||||||
import AnnotationsLocal from '/imports/ui/components/whiteboard/service';
|
import AnnotationsLocal from '/imports/ui/components/whiteboard/service';
|
||||||
import mapUser from '/imports/ui/services/user/mapUser';
|
import mapUser from '/imports/ui/services/user/mapUser';
|
||||||
import { withJoinLoadingConsumer } from '/imports/ui/components/join-loading/context/context';
|
|
||||||
|
|
||||||
const CHAT_CONFIG = Meteor.settings.public.chat;
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
||||||
const CHAT_ENABLED = CHAT_CONFIG.enabled;
|
const CHAT_ENABLED = CHAT_CONFIG.enabled;
|
||||||
@ -35,7 +34,7 @@ class Subscriptions extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withJoinLoadingConsumer(withTracker(({ dispatch }) => {
|
export default withTracker(() => {
|
||||||
const { credentials } = Auth;
|
const { credentials } = Auth;
|
||||||
const { meetingId, requesterUserId } = credentials;
|
const { meetingId, requesterUserId } = credentials;
|
||||||
if (Session.get('codeError')) {
|
if (Session.get('codeError')) {
|
||||||
@ -51,7 +50,6 @@ export default withJoinLoadingConsumer(withTracker(({ dispatch }) => {
|
|||||||
extraInfo: { error },
|
extraInfo: { error },
|
||||||
}, 'Error while subscribing to collections');
|
}, 'Error while subscribing to collections');
|
||||||
Session.set('codeError', error.error);
|
Session.set('codeError', error.error);
|
||||||
dispatch('hasError');
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -117,4 +115,4 @@ export default withJoinLoadingConsumer(withTracker(({ dispatch }) => {
|
|||||||
subscriptionsReady: ready,
|
subscriptionsReady: ready,
|
||||||
subscriptionsHandlers,
|
subscriptionsHandlers,
|
||||||
};
|
};
|
||||||
})(Subscriptions));
|
})(Subscriptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user