Skip to content

Commit 6cb7fed

Browse files
Fix sample app issue where after selecting pstn call then switching to start group call, the calls fails trying to make a PSTN call (#3962)
1 parent 0a7f776 commit 6cb7fed

4 files changed

Lines changed: 49 additions & 11 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Fix sample appl issue where after selecting pstn call then switching to start group call, the calls fails trying to make a PSTN call",
6+
"packageName": "@azure/communication-react",
7+
"email": "2684369+JamesBurnside@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Fix sample appl issue where after selecting pstn call then switching to start group call, the calls fails trying to make a PSTN call",
6+
"packageName": "@azure/communication-react",
7+
"email": "2684369+JamesBurnside@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}

samples/Calling/src/app/App.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,22 @@ const App = (): JSX.Element => {
110110
/* @conditional-compile-remove(PSTN-calls) */
111111
setAlternateCallerId(callDetails.alternateCallerId);
112112
let callLocator: CallAdapterLocator | undefined =
113-
callDetails.callLocator || getTeamsLinkFromUrl() || getGroupIdFromUrl();
113+
callDetails.callLocator || getTeamsLinkFromUrl() || getGroupIdFromUrl() || createGroupId();
114114

115115
/* @conditional-compile-remove(rooms) */
116-
callLocator = callLocator || getRoomIdFromUrl();
116+
if (callDetails.option === 'Rooms') {
117+
callLocator = getRoomIdFromUrl() || callDetails.callLocator;
118+
}
117119

118120
/* @conditional-compile-remove(PSTN-calls) */
119-
callLocator = callLocator || getOutboundParticipants(callDetails.outboundParticipants);
121+
if (callDetails.option === '1:N' || callDetails.option === 'PSTN') {
122+
callLocator = getOutboundParticipants(callDetails.outboundParticipants);
123+
}
120124

121125
/* @conditional-compile-remove(teams-adhoc-call) */
122-
callLocator = callLocator || getOutboundParticipants(callDetails.outboundTeamsUsers);
123-
124-
callLocator = callLocator || createGroupId();
126+
if (callDetails.option === 'TeamsAdhoc') {
127+
callLocator = getOutboundParticipants(callDetails.outboundTeamsUsers);
128+
}
125129

126130
/* @conditional-compile-remove(rooms) */
127131
// There is an API call involved with creating a room so lets only create one if we know we have to
@@ -136,6 +140,10 @@ const App = (): JSX.Element => {
136140
callLocator = { roomId: roomId };
137141
}
138142

143+
if (!callLocator) {
144+
throw new Error('Invalid call locator', callLocator);
145+
}
146+
139147
/* @conditional-compile-remove(rooms) */
140148
if ('roomId' in callLocator) {
141149
if (userId && 'communicationUserId' in userId) {
@@ -148,6 +156,7 @@ const App = (): JSX.Element => {
148156
throw 'Invalid userId!';
149157
}
150158
}
159+
151160
setCallLocator(callLocator);
152161

153162
// Update window URL to have a joinable link

samples/Calling/src/app/views/HomeScreen.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ import { useIsMobile } from '../utils/useIsMobile';
5050
import { useBoolean, useId } from '@fluentui/react-hooks';
5151
import { CallAdapterLocator } from '@azure/communication-react';
5252

53+
export type CallOption =
54+
| 'ACSCall'
55+
| 'TeamsMeeting'
56+
| /* @conditional-compile-remove(rooms) */ 'Rooms'
57+
| /* @conditional-compile-remove(rooms) */ 'StartRooms'
58+
| /* @conditional-compile-remove(teams-identity-support) */ 'TeamsIdentity'
59+
| /* @conditional-compile-remove(one-to-n-calling) */ '1:N'
60+
| /* @conditional-compile-remove(PSTN-calls) */ 'PSTN'
61+
| /* @conditional-compile-remove(teams-adhoc-call) */ 'TeamsAdhoc';
62+
5363
export interface HomeScreenProps {
5464
startCallHandler(callDetails: {
5565
displayName: string;
5666
callLocator?: CallAdapterLocator | TeamsMeetingLinkLocator | /* @conditional-compile-remove(rooms) */ RoomLocator;
57-
/* @conditional-compile-remove(rooms) */
58-
option?: string;
67+
option?: CallOption;
5968
/* @conditional-compile-remove(rooms) */
6069
role?: string;
6170
/* @conditional-compile-remove(PSTN-calls) */
@@ -72,12 +81,14 @@ export interface HomeScreenProps {
7281
joiningExistingCall: boolean;
7382
}
7483

84+
type ICallChoiceGroupOption = IChoiceGroupOption & { key: CallOption };
85+
7586
export const HomeScreen = (props: HomeScreenProps): JSX.Element => {
7687
const imageProps = { src: heroSVG.toString() };
7788
const headerTitle = props.joiningExistingCall ? 'Join Call' : 'Start or join a call';
7889
const callOptionsGroupLabel = 'Select a call option';
7990
const buttonText = 'Next';
80-
const callOptions: IChoiceGroupOption[] = [
91+
const callOptions: ICallChoiceGroupOption[] = [
8192
{ key: 'ACSCall', text: 'Start a call' },
8293
/* @conditional-compile-remove(rooms) */
8394
{ key: 'StartRooms', text: 'Start a Rooms call' },
@@ -112,7 +123,7 @@ export const HomeScreen = (props: HomeScreenProps): JSX.Element => {
112123
const defaultDisplayName = localStorageAvailable ? getDisplayNameFromLocalStorage() : null;
113124
const [displayName, setDisplayName] = useState<string | undefined>(defaultDisplayName ?? undefined);
114125

115-
const [chosenCallOption, setChosenCallOption] = useState<IChoiceGroupOption>(callOptions[0]);
126+
const [chosenCallOption, setChosenCallOption] = useState<ICallChoiceGroupOption>(callOptions[0]);
116127
const [callLocator, setCallLocator] = useState<
117128
TeamsMeetingLinkLocator | /* @conditional-compile-remove(rooms) */ RoomLocator
118129
>();
@@ -196,7 +207,7 @@ export const HomeScreen = (props: HomeScreenProps): JSX.Element => {
196207
defaultSelectedKey="ACSCall"
197208
options={callOptions}
198209
required={true}
199-
onChange={(_, option) => option && setChosenCallOption(option)}
210+
onChange={(_, option) => option && setChosenCallOption(option as ICallChoiceGroupOption)}
200211
/>
201212
)}
202213
{(teamsCallChosen || /* @conditional-compile-remove(teams-identity-support) */ teamsIdentityChosen) && (

0 commit comments

Comments
 (0)