Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
carocao-msft committed Dec 25, 2024
1 parent d8acf9d commit a2db45c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 13 additions & 1 deletion packages/calling-component-bindings/src/captionsSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,24 @@ export const captionsBannerSelector: CaptionsBannerSelector = reselect.createSel
isLocalUser: c.isLocal
};
});

/* @conditional-compile-remove(rtt) */
// find the last real time text caption
const lastRealTimeText =
captionsInfo &&
captionsInfo
.slice()
.reverse()
.find((caption) => caption.isRealTimeText && caption.isLocalUser);

return {
captions: captionsInfo ?? [],
isCaptionsOn: isCaptionsFeatureActive ?? false,
/* @conditional-compile-remove(rtt) */
isRealTimeTextOn: isRealTimeTextActive ?? false,
startCaptionsInProgress: startCaptionsInProgress ?? false
startCaptionsInProgress: startCaptionsInProgress ?? false,
/* @conditional-compile-remove(rtt) */
latestLocalRealTimeText: lastRealTimeText
};
}
);
Expand Down
19 changes: 11 additions & 8 deletions packages/react-components/src/components/CaptionsBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export interface CaptionsBannerProps {
* Optional callback to send real time text.
*/
onSendRealTimeText?: (text: string, finalized?: boolean) => Promise<void>;
/* @conditional-compile-remove(rtt) */
/**
* Latest local real time text
*/
latestLocalRealTimeText?: CaptionsInformation;
}

const SCROLL_OFFSET_ALLOWANCE = 20;
Expand All @@ -142,7 +147,9 @@ export const CaptionsBanner = (props: CaptionsBannerProps): JSX.Element => {
/* @conditional-compile-remove(rtt) */
isRealTimeTextOn,
/* @conditional-compile-remove(rtt) */
onSendRealTimeText
onSendRealTimeText,
/* @conditional-compile-remove(rtt) */
latestLocalRealTimeText
} = props;
const localeStrings = useLocale().strings.captionsBanner;
const strings = { ...localeStrings, ...props.strings };
Expand Down Expand Up @@ -187,15 +194,11 @@ export const CaptionsBanner = (props: CaptionsBannerProps): JSX.Element => {
/* @conditional-compile-remove(rtt) */
useEffect(() => {
// if the latest real time text sent by myself is final, clear the text field
// find the last real time text caption
const lastRealTimeText = captions
.slice()
.reverse()
.find((caption) => caption.isRealTimeText && caption.isLocalUser);
if (lastRealTimeText && !lastRealTimeText.isPartial) {
if (latestLocalRealTimeText && !latestLocalRealTimeText.isPartial) {
setTextFieldValue('');
}
}, [captions]);
}, [latestLocalRealTimeText]);

/* @conditional-compile-remove(rtt) */
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
if (event.key === 'Enter') {
Expand Down

0 comments on commit a2db45c

Please sign in to comment.