♻️(frontend) introduce a reusable isTranscriptEnabled
Encapsulate the logic, checking if the feature is enabled in the backend, in a proper and reusable hook.
This commit is contained in:
committed by
aleb_the_flash
parent
b342b9d526
commit
31468a5e7c
@@ -5,6 +5,7 @@ import { useSidePanel } from '@/features/rooms/livekit/hooks/useSidePanel'
|
|||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||||
|
import { useIsTranscriptEnabled } from '@/features/rooms/livekit/hooks/useIsTranscriptEnabled'
|
||||||
|
|
||||||
export const TranscriptToggle = () => {
|
export const TranscriptToggle = () => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'controls.transcript' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'controls.transcript' })
|
||||||
@@ -14,8 +15,10 @@ export const TranscriptToggle = () => {
|
|||||||
|
|
||||||
const featureEnabled = useFeatureFlagEnabled('transcription-summary')
|
const featureEnabled = useFeatureFlagEnabled('transcription-summary')
|
||||||
const isAnalyticsEnabled = useIsAnalyticsEnabled()
|
const isAnalyticsEnabled = useIsAnalyticsEnabled()
|
||||||
|
const isTranscriptEnabled = useIsTranscriptEnabled()
|
||||||
|
|
||||||
if (!featureEnabled && isAnalyticsEnabled) return
|
if (!featureEnabled && isAnalyticsEnabled) return
|
||||||
|
if (!isTranscriptEnabled) return
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { RecordingMode } from '@/features/rooms/api/startRecording'
|
||||||
|
import { useConfig } from '@/api/useConfig'
|
||||||
|
|
||||||
|
export const useIsTranscriptEnabled = () => {
|
||||||
|
const { data } = useConfig()
|
||||||
|
|
||||||
|
return (
|
||||||
|
data?.recording?.is_enabled &&
|
||||||
|
data?.recording?.available_modes?.includes(RecordingMode.Transcript)
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user