Skip to content

Commit 5020287

Browse files
[DTMF Dialer] remove old dtmf experience and update long press (#4065)
* Fix Dialpad bugs * Change files * Duplicate change files for beta release * fix tab away sound keeps playing * fix cc * use correct key values * fix tests * use Call start time to track the call timer * fix lint * fix build * Remove old DTMF experience * Change files * Duplicate change files for beta release * update API * stable component file * fix sample dialpads
1 parent 91e1934 commit 5020287

15 files changed

Lines changed: 63 additions & 232 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "feature",
4+
"workstream": "DTMF Dialer",
5+
"comment": "Remove old DTMF experience and update dialpad API to be platform agnostic",
6+
"packageName": "@azure/communication-react",
7+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "feature",
4+
"workstream": "DTMF Dialer",
5+
"comment": "Remove old DTMF experience and update dialpad API to be platform agnostic",
6+
"packageName": "@azure/communication-react",
7+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/communication-react/review/beta/communication-react.api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ export type DialpadMode = 'dtmf' | 'dialer';
26942694
export interface DialpadProps {
26952695
dialpadMode?: DialpadMode;
26962696
disableDtmfPlayback?: boolean;
2697-
isMobile?: boolean;
2697+
longPressTrigger?: LongPressTrigger;
26982698
onChange?: (input: string) => void;
26992699
onClickDialpadButton?: (buttonValue: string, buttonIndex: number) => void;
27002700
onSendDtmfTone?: (dtmfTone: DtmfTone) => Promise<void>;
@@ -3132,6 +3132,9 @@ export interface LocalVideoTileOptions {
31323132
// @public
31333133
export type LocalVideoTileSize = '9:16' | '16:9' | 'hidden' | 'followDeviceOrientation';
31343134

3135+
// @beta
3136+
export type LongPressTrigger = 'mouseAndTouch' | 'touch';
3137+
31353138
// @public
31363139
export type MediaDiagnosticChangedEvent = MediaDiagnosticChangedEventArgs & {
31373140
type: 'media';

packages/communication-react/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,14 @@ export type { ImageGalleryProps, ImageGalleryImageProps, ImageGalleryStrings } f
312312
/* @conditional-compile-remove(data-loss-prevention) */
313313
export type { BlockedMessage } from '../../react-components/src';
314314
/* @conditional-compile-remove(dialpad) */ /* @conditional-compile-remove(PSTN-calls) */
315-
export type { DialpadMode, DialpadProps, DialpadStrings, DialpadStyles, DtmfTone } from '../../react-components/src';
315+
export type {
316+
DialpadMode,
317+
DialpadProps,
318+
DialpadStrings,
319+
DialpadStyles,
320+
DtmfTone,
321+
LongPressTrigger
322+
} from '../../react-components/src';
316323
/* @conditional-compile-remove(file-sharing) */
317324
export type {
318325
ActiveFileUpload,

packages/react-components/review/beta/react-components.api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ export type DialpadMode = 'dtmf' | 'dialer';
971971
export interface DialpadProps {
972972
dialpadMode?: DialpadMode;
973973
disableDtmfPlayback?: boolean;
974-
isMobile?: boolean;
974+
longPressTrigger?: LongPressTrigger;
975975
onChange?: (input: string) => void;
976976
onClickDialpadButton?: (buttonValue: string, buttonIndex: number) => void;
977977
onSendDtmfTone?: (dtmfTone: DtmfTone) => Promise<void>;
@@ -1421,6 +1421,9 @@ export const _LocalVideoTile: React_2.MemoExoticComponent<(props: {
14211421
// @public
14221422
export type LocalVideoTileSize = '9:16' | '16:9' | 'hidden' | 'followDeviceOrientation';
14231423

1424+
// @beta
1425+
export type LongPressTrigger = 'mouseAndTouch' | 'touch';
1426+
14241427
// @beta
14251428
export interface Mention {
14261429
displayText: string;

packages/react-components/review/stable/react-components.api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ export type DialpadMode = 'dtmf' | 'dialer';
743743
export interface DialpadProps {
744744
dialpadMode?: DialpadMode;
745745
disableDtmfPlayback?: boolean;
746-
isMobile?: boolean;
746+
longPressTrigger?: LongPressTrigger;
747747
onChange?: (input: string) => void;
748748
onClickDialpadButton?: (buttonValue: string, buttonIndex: number) => void;
749749
onSendDtmfTone?: (dtmfTone: DtmfTone) => Promise<void>;
@@ -1125,6 +1125,9 @@ export const _LocalVideoTile: React_2.MemoExoticComponent<(props: {
11251125
// @public
11261126
export type LocalVideoTileSize = '9:16' | '16:9' | 'hidden' | 'followDeviceOrientation';
11271127

1128+
// @beta
1129+
export type LongPressTrigger = 'mouseAndTouch' | 'touch';
1130+
11281131
// @public
11291132
export type Message = ChatMessage | SystemMessage | CustomMessage;
11301133

packages/react-components/src/components/Dialpad/Dialpad.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ export type DtmfTone =
8686
*/
8787
export type DialpadMode = 'dtmf' | 'dialer';
8888

89+
/**
90+
* Modes of how the longpress handlers can be tiggered.
91+
* @beta
92+
*/
93+
export type LongPressTrigger = 'mouseAndTouch' | 'touch';
94+
8995
/**
9096
* Props for {@link Dialpad} component.
9197
*
@@ -114,9 +120,10 @@ export interface DialpadProps {
114120
*/
115121
showDeleteButton?: boolean;
116122
/**
117-
* flag to determine if dialpad is in mobile view, default false
123+
* Determines what kind of device that the user is on and should respect that based on interaction
124+
* interfaces available to the user
118125
*/
119-
isMobile?: boolean;
126+
longPressTrigger?: LongPressTrigger;
120127
/**
121128
* Styles for customizing the dialpad component
122129
*/
@@ -178,13 +185,13 @@ const DialpadButton = (props: {
178185
index: number;
179186
onClick: (input: string, index: number) => void;
180187
onLongPress: (input: string, index: number) => void;
181-
isMobile?: boolean;
188+
longPressTrigger: LongPressTrigger;
182189
dtmfToneAudioContext: AudioContext;
183190
disableDtmfPlayback?: boolean;
184191
}): JSX.Element => {
185192
const theme = useTheme();
186193

187-
const { digit, index, onClick, onLongPress, isMobile = false, dtmfToneAudioContext, disableDtmfPlayback } = props;
194+
const { digit, index, onClick, onLongPress, longPressTrigger, dtmfToneAudioContext, disableDtmfPlayback } = props;
188195
const [buttonPressed, setButtonPressed] = useState(false);
189196

190197
const dtmfToneSound = useRef<Tone>(
@@ -199,9 +206,9 @@ const DialpadButton = (props: {
199206
onLongPress: async () => {
200207
onLongPress(digit, index);
201208
},
202-
touchEventsOnly: isMobile
209+
touchEventsOnly: longPressTrigger === 'touch'
203210
}),
204-
[digit, index, isMobile, onClick, onLongPress]
211+
[digit, index, longPressTrigger, onClick, onLongPress]
205212
);
206213

207214
const longPressHandlers = useLongPress(useLongPressProps);
@@ -284,7 +291,7 @@ const DialpadContainer = (props: {
284291
/** boolean input to determine when to show/hide delete button, default true */
285292
showDeleteButton?: boolean;
286293
/** boolean input to determine if dialpad is in mobile view, default false */
287-
isMobile?: boolean;
294+
longPressTrigger?: LongPressTrigger;
288295
styles?: DialpadStyles;
289296
disableDtmfPlayback?: boolean;
290297
dialpadMode?: DialpadMode;
@@ -297,7 +304,7 @@ const DialpadContainer = (props: {
297304
textFieldValue,
298305
onChange,
299306
showDeleteButton = true,
300-
isMobile = false,
307+
longPressTrigger = 'mouseAndTouch',
301308
disableDtmfPlayback,
302309
dialpadMode = 'dialer'
303310
} = props;
@@ -418,7 +425,7 @@ const DialpadContainer = (props: {
418425
styles={props.styles}
419426
onClick={onClickDialpad}
420427
onLongPress={onLongPressDialpad}
421-
isMobile={isMobile}
428+
longPressTrigger={longPressTrigger}
422429
dtmfToneAudioContext={dtmfToneAudioContext.current}
423430
disableDtmfPlayback={disableDtmfPlayback}
424431
/>

packages/react-components/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export { _ComplianceBanner } from './ComplianceBanner';
211211
export type { _ComplianceBannerProps, _ComplianceBannerStrings } from './ComplianceBanner';
212212
export { Dialpad } from './Dialpad/Dialpad';
213213
export type { DialpadProps, DialpadStrings, DialpadStyles, DtmfTone } from './Dialpad/Dialpad';
214-
export type { DialpadMode } from './Dialpad/Dialpad';
214+
export type { DialpadMode, LongPressTrigger } from './Dialpad/Dialpad';
215215
/* @conditional-compile-remove(end-of-call-survey) */
216216
export { _StarSurvey } from './Survey/StarSurvey/StarSurvey';
217217
/* @conditional-compile-remove(end-of-call-survey) */

packages/react-composites/src/composites/CallComposite/components/CallArrangement.tsx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ import { useSelector } from '../hooks/useSelector';
4646
import { callStatusSelector } from '../selectors/callStatusSelector';
4747
import { CallControlOptions } from '../types/CallControlOptions';
4848
import { PreparedMoreDrawer } from '../../common/Drawer/PreparedMoreDrawer';
49-
/* @conditional-compile-remove(PSTN-calls) */
50-
import { SendDtmfDialpad } from '../../common/SendDtmfDialpad';
51-
/* @conditional-compile-remove(PSTN-calls) */
52-
import { useCallWithChatCompositeStrings } from '../../CallWithChatComposite/hooks/useCallWithChatCompositeStrings';
5349
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
5450
import { getPage } from '../selectors/baseSelectors';
5551
/* @conditional-compile-remove(close-captions) */
@@ -210,19 +206,6 @@ export const CallArrangement = (props: CallArrangementProps): JSX.Element => {
210206
};
211207
}, [isMobileWithActivePane, props.mobileView]);
212208

213-
/* @conditional-compile-remove(PSTN-calls) */
214-
const callWithChatStrings = useCallWithChatCompositeStrings();
215-
216-
/* @conditional-compile-remove(PSTN-calls) */
217-
const dialpadStrings = useMemo(
218-
() => ({
219-
dialpadModalAriaLabel: callWithChatStrings.dialpadModalAriaLabel,
220-
dialpadCloseModalButtonAriaLabel: callWithChatStrings.dialpadCloseModalButtonAriaLabel,
221-
placeholderText: callWithChatStrings.dtmfDialpadPlaceholderText
222-
}),
223-
[callWithChatStrings]
224-
);
225-
226209
/* @conditional-compile-remove(video-background-effects) */
227210
const onResolveVideoEffectDependency = adapter.getState().onResolveVideoEffectDependency;
228211

@@ -246,22 +229,6 @@ export const CallArrangement = (props: CallArrangementProps): JSX.Element => {
246229
togglePeoplePane();
247230
}, [togglePeoplePane]);
248231

249-
/* @conditional-compile-remove(PSTN-calls) */
250-
const alternateCallerId = useAdapter().getState().alternateCallerId;
251-
252-
/* @conditional-compile-remove(PSTN-calls) */
253-
const [showDtmfDialpad, setShowDtmfDialpad] = useState(false);
254-
255-
/* @conditional-compile-remove(PSTN-calls) */
256-
const onDismissDtmfDialpad = (): void => {
257-
setShowDtmfDialpad(false);
258-
};
259-
260-
/* @conditional-compile-remove(PSTN-calls) */
261-
const onClickShowDialpad = (): void => {
262-
setShowDtmfDialpad(true);
263-
};
264-
265232
const drawerContainerStylesValue = useMemo(() => drawerContainerStyles(DRAWER_Z_INDEX), []);
266233

267234
/* @conditional-compile-remove(rooms) */
@@ -358,8 +325,6 @@ export const CallArrangement = (props: CallArrangementProps): JSX.Element => {
358325
isCaptionsOn={isCaptionsOn}
359326
/* @conditional-compile-remove(video-background-effects) */
360327
onClickVideoEffects={onResolveVideoEffectDependency ? openVideoEffectsPane : undefined}
361-
/* @conditional-compile-remove(PSTN-calls) */
362-
onClickShowDialpad={alternateCallerId ? onClickShowDialpad : undefined}
363328
displayVertical={verticalControlBar}
364329
/* @conditional-compile-remove(gallery-layouts) */
365330
onUserSetOverflowGalleryPositionChange={props.onUserSetOverflowGalleryPositionChange}
@@ -383,8 +348,6 @@ export const CallArrangement = (props: CallArrangementProps): JSX.Element => {
383348
callControls={props.callControlProps.options}
384349
onLightDismiss={closeDrawer}
385350
onPeopleButtonClicked={onMoreDrawerPeopleClicked}
386-
/* @conditional-compile-remove(PSTN-calls) */
387-
onClickShowDialpad={alternateCallerId ? onClickShowDialpad : undefined}
388351
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
389352
disableButtonsForHoldScreen={isInLocalHold}
390353
/* @conditional-compile-remove(close-captions) */
@@ -400,20 +363,6 @@ export const CallArrangement = (props: CallArrangementProps): JSX.Element => {
400363
/>
401364
</Stack>
402365
)}
403-
404-
{
405-
/* @conditional-compile-remove(PSTN-calls) */
406-
props.callControlProps?.options !== false && showDtmfDialpad && (
407-
<Stack styles={drawerContainerStylesValue}>
408-
<SendDtmfDialpad
409-
isMobile={props.mobileView}
410-
strings={dialpadStrings}
411-
showDialpad={showDtmfDialpad}
412-
onDismissDialpad={onDismissDtmfDialpad}
413-
/>
414-
</Stack>
415-
)
416-
}
417366
<Stack horizontal grow>
418367
<Stack.Item style={callCompositeContainerCSS}>
419368
<Stack.Item styles={callGalleryStyles} grow>

packages/react-composites/src/composites/CallComposite/components/CallControls.tsx

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import { memoizeFunction, Stack, useTheme } from '@fluentui/react';
55
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */ /* @conditional-compile-remove(close-captions) */ /* @conditional-compile-remove(raise-hand) */
66
import { IContextualMenuItem } from '@fluentui/react';
7-
/* @conditional-compile-remove(PSTN-calls) */
8-
import { useState } from 'react';
97
import { _isInLobbyOrConnecting } from '@internal/calling-component-bindings';
108
import { ControlBar, DevicesButton, ParticipantMenuItemsCallback } from '@internal/react-components';
119
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
@@ -29,8 +27,6 @@ import { MoreButton } from '../../common/MoreButton';
2927
import { usePropsFor } from '../hooks/usePropsFor';
3028
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */ /* @conditional-compile-remove(close-captions) */ /* @conditional-compile-remove(raise-hand) */
3129
import { buttonFlyoutIncreasedSizeStyles } from '../styles/Buttons.styles';
32-
/* @conditional-compile-remove(PSTN-calls) */
33-
import { SendDtmfDialpad } from '../../common/SendDtmfDialpad';
3430
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(rooms) */
3531
import { useAdapter } from '../adapter/CallAdapterProvider';
3632
import { isDisabled } from '../utils';
@@ -126,16 +122,6 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
126122
[localeStrings]
127123
);
128124

129-
/* @conditional-compile-remove(PSTN-calls) */
130-
const dialpadStrings = useMemo(
131-
() => ({
132-
dialpadModalAriaLabel: localeStrings.strings.call.dialpadModalAriaLabel,
133-
dialpadCloseModalButtonAriaLabel: localeStrings.strings.call.dialpadCloseModalButtonAriaLabel,
134-
placeholderText: localeStrings.strings.call.dtmfDialpadPlaceholderText
135-
}),
136-
[localeStrings]
137-
);
138-
139125
/* @conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
140126
const holdButtonProps = usePropsFor(HoldButton);
141127

@@ -148,9 +134,6 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
148134
const isReactionAllowed =
149135
!capabilitiesSelector?.capabilities || capabilitiesSelector.capabilities.useReactions.isPresent;
150136

151-
/* @conditional-compile-remove(PSTN-calls) */
152-
const alternateCallerId = useAdapter().getState().alternateCallerId;
153-
154137
const devicesButtonProps = usePropsFor(DevicesButton);
155138

156139
let numberOfButtons = 0;
@@ -226,22 +209,6 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
226209
['data-ui-id']: 'hold-button'
227210
});
228211
}
229-
230-
/* @conditional-compile-remove(PSTN-calls) */
231-
// dtmf tone sending only works for 1:1 PSTN call
232-
if (alternateCallerId) {
233-
items.push({
234-
key: 'showDialpadKey',
235-
text: localeStrings.strings.call.openDtmfDialpadLabel,
236-
onClick: () => {
237-
setShowDialpad(true);
238-
},
239-
iconProps: { iconName: 'PeoplePaneOpenDialpad', styles: { root: { lineHeight: 0 } } },
240-
itemProps: {
241-
styles: buttonFlyoutIncreasedSizeStyles
242-
}
243-
});
244-
}
245212
return items;
246213
};
247214

@@ -373,32 +340,15 @@ export const CallControls = (props: CallControlsProps & ContainerRectProps): JSX
373340
});
374341
}
375342

376-
/* @conditional-compile-remove(PSTN-calls) */
377-
const [showDialpad, setShowDialpad] = useState(false);
378-
379343
const theme = useTheme();
380344

381345
// when props.options is false then we want to hide the whole control bar.
382346
if (props.options === false) {
383347
return <></>;
384348
}
385349

386-
/* @conditional-compile-remove(PSTN-calls) */
387-
const onDismissDialpad = (): void => {
388-
setShowDialpad(false);
389-
};
390-
391350
return (
392351
<Stack horizontalAlign="center" className={callControlsContainerStyles}>
393-
{
394-
/* @conditional-compile-remove(PSTN-calls) */
395-
<SendDtmfDialpad
396-
isMobile={!!props.isMobile}
397-
strings={dialpadStrings}
398-
showDialpad={showDialpad}
399-
onDismissDialpad={onDismissDialpad}
400-
/>
401-
}
402352
<Stack.Item>
403353
{/*
404354
Note: We use the layout="horizontal" instead of dockedBottom because of how we position the

0 commit comments

Comments
 (0)