Skip to content

Commit

Permalink
Revert "Allow user to start an incoming call asynchronously for testi…
Browse files Browse the repository at this point in the history
…ng (#146)"

This reverts commit 9800470.
  • Loading branch information
alonso-cadenas committed Aug 4, 2023
1 parent 9800470 commit 50e6d45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 34 deletions.
13 changes: 3 additions & 10 deletions demos/demo-minimal-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@
value="user unavailable"
/>
<p>4. Start a call</p>
<input
disabled
id="outgoingcall"
onclick="outgoingCall()"
type="button"
value="outgoing call started"
/>
<input
disabled
id="incomingcall"
Expand All @@ -156,10 +149,10 @@
/>
<input
disabled
id="incomingcallasync"
onclick="incomingCallAsync(3000)"
id="outgoingcall"
onclick="outgoingCall()"
type="button"
value="incoming call started in 3s"
value="outgoing call started"
/>
<input
disabled
Expand Down
33 changes: 9 additions & 24 deletions demos/demo-minimal-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const ANSWER_CALL = "answercall";
const COMPLETE_CALL = "completecall";
const END_CALL = "endcall";
const INCOMING_CALL = "incomingcall";
const INCOMING_CALL_ASYNC = "incomingcallasync";
const INITIALIZE = "initialize";
const LOG_IN = "login";
const LOG_OUT = "logout";
Expand Down Expand Up @@ -88,9 +87,9 @@ export function logIn() {
enableButtons([LOG_OUT, OUTGOING_CALL]);
if (state.userAvailable) {
disableButtons([USER_AVAILABLE]);
enableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
enableButtons([INCOMING_CALL, USER_UNAVAILABLE]);
} else {
disableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
disableButtons([INCOMING_CALL, USER_UNAVAILABLE]);
enableButtons([USER_AVAILABLE]);
}
}
Expand All @@ -114,13 +113,13 @@ export function userAvailable() {
cti.userAvailable();
state.userAvailable = true;
disableButtons([USER_AVAILABLE]);
enableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
enableButtons([INCOMING_CALL, USER_UNAVAILABLE]);
}

export function userUnavailable() {
cti.userUnavailable();
state.userAvailable = false;
disableButtons([INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
disableButtons([INCOMING_CALL, USER_UNAVAILABLE]);
enableButtons([USER_AVAILABLE]);
}

Expand All @@ -131,21 +130,9 @@ export function incomingCall() {
fromNumber: "+123",
toNumber: state.phoneNumber,
});
enableButtons([ANSWER_CALL, END_CALL]);
}, 500);
disableButtons([OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
}

export function incomingCallAsync(time) {
window.setTimeout(() => {
cti.incomingCall({
createEngagement: "true",
fromNumber: "+123",
toNumber: state.phoneNumber,
});
enableButtons([ANSWER_CALL, END_CALL]);
}, time);
disableButtons([OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);
enableButtons([ANSWER_CALL, END_CALL]);
}

export function outgoingCall() {
Expand All @@ -154,11 +141,9 @@ export function outgoingCall() {
createEngagement: "true",
phoneNumber: state.phoneNumber,
});
enableButtons([ANSWER_CALL, END_CALL]);
}, 500);
disableButtons([
OUTGOING_CALL, INCOMING_CALL, INCOMING_CALL_ASYNC, USER_UNAVAILABLE, USER_UNAVAILABLE,
]);
disableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);
enableButtons([ANSWER_CALL, END_CALL]);
}

export function answerCall() {
Expand All @@ -180,7 +165,7 @@ export function completeCall() {
hideWidget: false,
});
disableButtons([COMPLETE_CALL]);
enableButtons([OUTGOING_CALL, INCOMING_CALL,INCOMING_CALL_ASYNC, USER_UNAVAILABLE]);
enableButtons([OUTGOING_CALL, INCOMING_CALL, USER_UNAVAILABLE]);
}

export function sendError() {
Expand Down

0 comments on commit 50e6d45

Please sign in to comment.