@azure/communication-react 1.2.3-alpha-202205130015.0 → 1.2.3-alpha-202205140015.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist-cjs/communication-react/index.js +87 -22
- package/dist/dist-cjs/communication-react/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/react-components/src/components/ComplianceBanner/ComplianceBanner.d.ts.map +1 -1
- package/dist/dist-esm/react-components/src/components/ComplianceBanner/ComplianceBanner.js +86 -21
- package/dist/dist-esm/react-components/src/components/ComplianceBanner/ComplianceBanner.js.map +1 -1
- package/package.json +7 -7
@@ -191,7 +191,7 @@ const fromFlatCommunicationIdentifier = (id) => {
|
|
191
191
|
// Copyright (c) Microsoft Corporation.
|
192
192
|
// Licensed under the MIT license.
|
193
193
|
// GENERATED FILE. DO NOT EDIT MANUALLY.
|
194
|
-
var telemetryVersion = '1.2.3-alpha-
|
194
|
+
var telemetryVersion = '1.2.3-alpha-202205140015.0';
|
195
195
|
|
196
196
|
// Copyright (c) Microsoft Corporation.
|
197
197
|
/**
|
@@ -6809,6 +6809,7 @@ const computeVariant = (callRecordState, callTranscribeState) => {
|
|
6809
6809
|
};
|
6810
6810
|
|
6811
6811
|
// Copyright (c) Microsoft Corporation.
|
6812
|
+
const BANNER_OVERWRITE_DELAY_MS = 3000;
|
6812
6813
|
/**
|
6813
6814
|
* A component that displays banners to notify the user when call recording and
|
6814
6815
|
* transcription is enabled or disabled in a call.
|
@@ -6819,10 +6820,6 @@ const computeVariant = (callRecordState, callTranscribeState) => {
|
|
6819
6820
|
* @internal
|
6820
6821
|
*/
|
6821
6822
|
const _ComplianceBanner = (props) => {
|
6822
|
-
//set variant when incoming state is different from current state
|
6823
|
-
//when variant change, return message bar
|
6824
|
-
//when message bar is dismissed,set variant to default nostate and if current state is stopped, set to off
|
6825
|
-
const [variant, setVariant] = React.useState('NO_STATE');
|
6826
6823
|
const cachedProps = React.useRef({
|
6827
6824
|
latestBooleanState: {
|
6828
6825
|
callTranscribeState: false,
|
@@ -6831,39 +6828,46 @@ const _ComplianceBanner = (props) => {
|
|
6831
6828
|
latestStringState: {
|
6832
6829
|
callTranscribeState: 'off',
|
6833
6830
|
callRecordState: 'off'
|
6834
|
-
}
|
6831
|
+
},
|
6832
|
+
lastUpdated: Date.now()
|
6835
6833
|
});
|
6836
6834
|
// Only update cached props and variant if there is _some_ change in the latest props.
|
6837
6835
|
// This ensures that state machine is only updated if there is an actual change in the props.
|
6838
|
-
|
6839
|
-
props.callTranscribeState !== cachedProps.current.latestBooleanState.callTranscribeState
|
6836
|
+
const shouldUpdateCached = props.callRecordState !== cachedProps.current.latestBooleanState.callRecordState ||
|
6837
|
+
props.callTranscribeState !== cachedProps.current.latestBooleanState.callTranscribeState;
|
6838
|
+
// The following three operations must be performed in this exact order:
|
6839
|
+
// [1]: Update cached state to transition the state machine.
|
6840
|
+
if (shouldUpdateCached) {
|
6840
6841
|
cachedProps.current = {
|
6841
6842
|
latestBooleanState: props,
|
6842
6843
|
latestStringState: {
|
6843
6844
|
callRecordState: determineStates(cachedProps.current.latestStringState.callRecordState, props.callRecordState),
|
6844
6845
|
callTranscribeState: determineStates(cachedProps.current.latestStringState.callTranscribeState, props.callTranscribeState)
|
6845
|
-
}
|
6846
|
+
},
|
6847
|
+
lastUpdated: Date.now()
|
6846
6848
|
};
|
6847
|
-
setVariant(computeVariant(cachedProps.current.latestStringState.callRecordState, cachedProps.current.latestStringState.callTranscribeState));
|
6848
|
-
// when both states are stopped, after displaying message "RECORDING_AND_TRANSCRIPTION_STOPPED", change both states to off (going back to the default state)
|
6849
|
-
if (cachedProps.current.latestStringState.callRecordState === 'stopped' &&
|
6850
|
-
cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
|
6851
|
-
cachedProps.current.latestStringState.callRecordState = 'off';
|
6852
|
-
cachedProps.current.latestStringState.callTranscribeState = 'off';
|
6853
|
-
}
|
6854
6849
|
}
|
6855
|
-
|
6856
|
-
|
6857
|
-
|
6858
|
-
|
6850
|
+
// [2]: Compute the variant, using the transitioned state machine.
|
6851
|
+
const variant = computeVariant(cachedProps.current.latestStringState.callRecordState, cachedProps.current.latestStringState.callTranscribeState);
|
6852
|
+
// [3]: Transition the state machine again to deal with some end-states.
|
6853
|
+
if (shouldUpdateCached &&
|
6854
|
+
cachedProps.current.latestStringState.callRecordState === 'stopped' &&
|
6855
|
+
cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
|
6856
|
+
// When both states are stopped, after displaying message "RECORDING_AND_TRANSCRIPTION_STOPPED", change both states to off (going back to the default state).
|
6857
|
+
cachedProps.current.latestStringState.callRecordState = 'off';
|
6858
|
+
cachedProps.current.latestStringState.callTranscribeState = 'off';
|
6859
|
+
}
|
6860
|
+
return (React__default['default'].createElement(DelayedUpdateBanner, { variant: {
|
6861
|
+
variant,
|
6862
|
+
lastUpdated: cachedProps.current.lastUpdated
|
6863
|
+
}, strings: props.strings, onDismiss: () => {
|
6859
6864
|
if (cachedProps.current.latestStringState.callRecordState === 'stopped') {
|
6860
6865
|
cachedProps.current.latestStringState.callRecordState = 'off';
|
6861
6866
|
}
|
6862
6867
|
if (cachedProps.current.latestStringState.callTranscribeState === 'stopped') {
|
6863
6868
|
cachedProps.current.latestStringState.callTranscribeState = 'off';
|
6864
6869
|
}
|
6865
|
-
}
|
6866
|
-
React__default['default'].createElement(BannerMessage, { variant: variant, strings: props.strings })));
|
6870
|
+
} }));
|
6867
6871
|
};
|
6868
6872
|
function determineStates(previous, current) {
|
6869
6873
|
// if current state is on, then return on
|
@@ -6882,6 +6886,67 @@ function determineStates(previous, current) {
|
|
6882
6886
|
}
|
6883
6887
|
}
|
6884
6888
|
}
|
6889
|
+
/**
|
6890
|
+
* Shows a {@link BannerMessage} in a {@link MessageBar} tracking `variant` internally.
|
6891
|
+
*
|
6892
|
+
* This component delays and combines frequent updates to `variant` such that:
|
6893
|
+
* - Updates that happen within {@link BANNER_OVERWRITE_DELAY_MS} are delayed.
|
6894
|
+
* - Once {@link BANNER_OVERWRITE_DELAY_MS} has passed since the last update, the _latest_ pending update is shown.
|
6895
|
+
*
|
6896
|
+
* This ensures that there is enough time for the user to see a banner message before it is overwritten.
|
6897
|
+
* In case of multiple delayed messages, the user always sees the final message as it reflects the final state
|
6898
|
+
* of recording and transcription.
|
6899
|
+
*
|
6900
|
+
* @private
|
6901
|
+
*/
|
6902
|
+
function DelayedUpdateBanner(props) {
|
6903
|
+
const { variant, lastUpdated: variantLastUpdated } = props.variant;
|
6904
|
+
// Tracks the variant that is currently visible in the UI.
|
6905
|
+
const [visible, setVisible] = React.useState({
|
6906
|
+
variant,
|
6907
|
+
lastUpdated: Date.now()
|
6908
|
+
});
|
6909
|
+
const pendingUpdateHandle = React.useRef(null);
|
6910
|
+
if (variant !== visible.variant && variantLastUpdated > visible.lastUpdated) {
|
6911
|
+
// Always clear pending updates.
|
6912
|
+
// We'll either update now, or schedule an update for later.
|
6913
|
+
if (pendingUpdateHandle.current) {
|
6914
|
+
clearTimeout(pendingUpdateHandle.current);
|
6915
|
+
pendingUpdateHandle.current = null;
|
6916
|
+
}
|
6917
|
+
const now = Date.now();
|
6918
|
+
const timeToNextUpdate = BANNER_OVERWRITE_DELAY_MS - (now - visible.lastUpdated);
|
6919
|
+
if (variant === 'NO_STATE' || timeToNextUpdate <= 0) {
|
6920
|
+
setVisible({
|
6921
|
+
variant,
|
6922
|
+
lastUpdated: now
|
6923
|
+
});
|
6924
|
+
}
|
6925
|
+
else {
|
6926
|
+
pendingUpdateHandle.current = setTimeout(() => {
|
6927
|
+
// Set the actual update time, not the computed time when the update should happen.
|
6928
|
+
// The actual update might be later than we planned.
|
6929
|
+
setVisible({
|
6930
|
+
variant,
|
6931
|
+
lastUpdated: Date.now()
|
6932
|
+
});
|
6933
|
+
}, timeToNextUpdate);
|
6934
|
+
}
|
6935
|
+
}
|
6936
|
+
if (visible.variant === 'NO_STATE') {
|
6937
|
+
return React__default['default'].createElement(React__default['default'].Fragment, null);
|
6938
|
+
}
|
6939
|
+
return (React__default['default'].createElement(react.MessageBar, { messageBarType: react.MessageBarType.warning, onDismiss: () => {
|
6940
|
+
// when closing the banner, change variant to nostate and change stopped state to off state.
|
6941
|
+
// Reason: on banner close, going back to the default state.
|
6942
|
+
setVisible({
|
6943
|
+
variant: 'NO_STATE',
|
6944
|
+
lastUpdated: Date.now()
|
6945
|
+
});
|
6946
|
+
props.onDismiss();
|
6947
|
+
}, dismissButtonAriaLabel: props.strings.close },
|
6948
|
+
React__default['default'].createElement(BannerMessage, { variant: visible.variant, strings: props.strings })));
|
6949
|
+
}
|
6885
6950
|
function BannerMessage(props) {
|
6886
6951
|
const { variant, strings } = props;
|
6887
6952
|
switch (variant) {
|