♻️(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:
lebaudantoine
2024-12-03 22:55:23 +01:00
committed by aleb_the_flash
parent b342b9d526
commit 31468a5e7c
2 changed files with 14 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { useSidePanel } from '@/features/rooms/livekit/hooks/useSidePanel'
import { css } from '@/styled-system/css'
import { useFeatureFlagEnabled } from 'posthog-js/react'
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
import { useIsTranscriptEnabled } from '@/features/rooms/livekit/hooks/useIsTranscriptEnabled'
export const TranscriptToggle = () => {
const { t } = useTranslation('rooms', { keyPrefix: 'controls.transcript' })
@@ -14,8 +15,10 @@ export const TranscriptToggle = () => {
const featureEnabled = useFeatureFlagEnabled('transcription-summary')
const isAnalyticsEnabled = useIsAnalyticsEnabled()
const isTranscriptEnabled = useIsTranscriptEnabled()
if (!featureEnabled && isAnalyticsEnabled) return
if (!isTranscriptEnabled) return
return (
<div

View File

@@ -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)
)
}