prevents client freeze on race condition when customUserSettings set

This commit is contained in:
Anton Georgiev 2019-07-12 18:59:56 +00:00
parent b58f1953f0
commit 73e9b6d70f
2 changed files with 22 additions and 8 deletions

View File

@ -25,6 +25,7 @@ class JoinHandler extends Component {
super(props);
this.fetchToken = this.fetchToken.bind(this);
this.changeToJoin = this.changeToJoin.bind(this);
this.numFetchTokenRetries = 0;
this.state = {
joined: false,
@ -40,6 +41,19 @@ class JoinHandler extends Component {
}
async fetchToken() {
if (!Meteor.status().connected) {
if (this.numFetchTokenRetries > 9) {
logger.error({
logCode: 'joinhandler_component_joinroutehandler_error',
extraInfo: {
numFetchTokenRetries: this.numFetchTokenRetries,
},
}, 'Meteor was not connected, retry in a few moments');
}
this.numFetchTokenRetries += 1;
setTimeout(() => this.fetchToken(), 200);
}
const urlParams = new URLSearchParams(window.location.search);
const sessionToken = urlParams.get('sessionToken');
@ -102,7 +116,6 @@ class JoinHandler extends Component {
meetingID, internalUserID, customdata,
} = resp;
return new Promise((resolve) => {
if (customdata.length) {
makeCall('addUserSettings', meetingID, internalUserID, customdata).then(r => resolve(r));

View File

@ -11,12 +11,12 @@ import { notify } from '/imports/ui/services/notification';
* @return {Promise}
*/
export function makeCall(name, ...args) {
if (Meteor.status().connected) {
check(name, String);
check(name, String);
const { credentials } = Auth;
const { credentials } = Auth;
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if (Meteor.status().connected) {
Meteor.call(name, credentials, ...args, (error, result) => {
if (error) {
reject(error);
@ -24,9 +24,10 @@ export function makeCall(name, ...args) {
resolve(result);
});
});
}
return null;
} else {
reject(new Error('Meteor was not connected'));
}
});
}
/**