Skip to content

Commit

Permalink
refactor(CallCtrlPage, ConferenceCall): refine timing
Browse files Browse the repository at this point in the history
add await for promise.all of mergeToConference and use sleep() to wait
  • Loading branch information
Lex. Huang committed Jun 11, 2018
1 parent 376ab99 commit 7985368
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/ringcentral-integration/modules/ConferenceCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import permissionsMessages from '../RolesAndPermissions/permissionsMessages';
import conferenceErrors from './conferenceCallErrors';
// import webphoneErrors from '../Webphone/webphoneErrors';
import ensureExist from '../../lib/ensureExist';
import sleep from '../../lib/sleep';
import callingModes from '../CallingSettings/callingModes';

const DEFAULT_TTL = 5000;// timer to update the conference information
Expand Down Expand Up @@ -383,7 +384,7 @@ export default class ConferenceCall extends RcModule {
return p;
});

Promise.all([this._mergeToConference(webphoneSessions), ...pSips])
await Promise.all([this._mergeToConference(webphoneSessions), ...pSips])
.then(() => {
this.store.dispatch({
type: this.actionTypes.mergeSucceeded,
Expand Down Expand Up @@ -616,13 +617,12 @@ export default class ConferenceCall extends RcModule {
* HACK: terminate the session initiatively to avoid:
* 1. remaining session when duplicated session exsisting in a conference.
*/
setTimeout(() => {
webphoneSessions.forEach((webphoneSession) => {
if (webphoneSession && webphoneSession.id) {
this._webphone.hangup(webphoneSession.id);
}
});
}, this._spanForTermination);
await sleep(this._spanForTermination);
webphoneSessions.forEach((webphoneSession) => {
if (webphoneSession && webphoneSession.id) {
this._webphone.hangup(webphoneSession.id);
}
});

this.startPollingConferenceStatus(conferenceId);
return conferenceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function mapToFunctions(_, {
* because session termination operation in conferenceCall._mergeToConference,
* need to wait for webphone.getActiveSessionIdReducer to update
*/
setTimeout(() => conferenceData.session.unhold(), conferenceCall._spanForTermination + 1);
conferenceData.session.unhold();
}
},
setMergingFrom: from => conferenceCall.setMergeParty({ from }),
Expand Down

0 comments on commit 7985368

Please sign in to comment.