-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
"@livekit/components-core": patch | ||
"@livekit/components-react": patch | ||
--- | ||
|
||
Add useIsRecording hook |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { recordingStatusObservable } from '@livekit/components-core'; | ||
import * as React from 'react'; | ||
import { useRoomContext } from '../context'; | ||
import { useObservableState } from './internal'; | ||
import { useConnectionState } from './useConnectionStatus'; | ||
|
||
/** | ||
* The `useIsRecording` hook returns a `boolean` that indicates if the room is currently being recorded. | ||
* @example | ||
* ```tsx | ||
* const isRecording = useIsRecording(); | ||
* ``` | ||
* @public | ||
*/ | ||
export function useIsRecording() { | ||
const room = useRoomContext(); | ||
const connectionState = useConnectionState(room); | ||
const observable = React.useMemo(() => recordingStatusObservable(room), [room, connectionState]); | ||
const isRecording = useObservableState(observable, room.isRecording); | ||
|
||
return isRecording; | ||
} |