-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Release-blocker] composite audio context updates (#4539)
* move audio context to react context to minimize hook usage * fix build * Change files * Fix test
- Loading branch information
1 parent
27edcdb
commit c688200
Showing
9 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
change-beta/@azure-communication-react-fda0563f-1d07-44a9-b28f-c1e635e0b286.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type": "patch", | ||
"area": "fix", | ||
"workstream": "Calling Sounds", | ||
"comment": "Move internal CallComposite AudioContext to a react context to avoid over creation of audio contexts", | ||
"packageName": "@azure/communication-react", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
9 changes: 9 additions & 0 deletions
9
change/@azure-communication-react-fda0563f-1d07-44a9-b28f-c1e635e0b286.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type": "patch", | ||
"area": "fix", | ||
"workstream": "Calling Sounds", | ||
"comment": "Move internal CallComposite AudioContext to a react context to avoid over creation of audio contexts", | ||
"packageName": "@azure/communication-react", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/react-composites/src/composites/common/AudioProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React, { useContext, createContext } from 'react'; | ||
|
||
/** | ||
* @private | ||
*/ | ||
export interface ACSAudioProviderProps { | ||
audioContext: AudioContext; | ||
children: JSX.Element; | ||
} | ||
|
||
/** | ||
* | ||
* @param props | ||
* @returns | ||
*/ | ||
export const ACSAudioProvider = (props: ACSAudioProviderProps): JSX.Element => { | ||
const { audioContext, children } = props; | ||
const alreadyWrapped = useAudio(); | ||
if (alreadyWrapped) { | ||
return <>{children}</>; | ||
} | ||
return <ACSAudioContext.Provider value={audioContext}>{props.children}</ACSAudioContext.Provider>; | ||
}; | ||
|
||
/** | ||
* @private | ||
*/ | ||
const ACSAudioContext = createContext<AudioContext>(new AudioContext()); | ||
|
||
/** | ||
* @private | ||
*/ | ||
export const useAudio = (): AudioContext => useContext(ACSAudioContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters