Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

♻️(frontend) generalize recording availability hook for all types

lebaudantoinea22d052f4664
diff --git a/src/frontend/src/features/rooms/livekit/components/Tools.tsx b/src/frontend/src/features/rooms/livekit/components/Tools.tsx
index ec58f6d7..8320d7b0 100644
--- a/src/frontend/src/features/rooms/livekit/components/Tools.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/Tools.tsx
@@ -6,8 +6,9 @@ import { CRISP_HELP_ARTICLE_MORE_TOOLS } from '@/utils/constants'
import { ReactNode } from 'react'
import { Transcript } from './Transcript'
import { RiFileTextFill } from '@remixicon/react'
-import { useIsTranscriptEnabled } from '../hooks/useIsTranscriptEnabled'
import { useSidePanel } from '../hooks/useSidePanel'
+import { useIsRecordingModeEnabled } from '../hooks/useIsRecordingModeEnabled'
+import { RecordingMode } from '@/features/rooms/api/startRecording'
export interface ToolsButtonProps {
icon: ReactNode
@@ -70,7 +71,9 @@ const ToolButton = ({
export const Tools = () => {
const { openTranscript, isTranscriptOpen } = useSidePanel()
const { t } = useTranslation('rooms', { keyPrefix: 'moreTools' })
- const isTranscriptEnabled = useIsTranscriptEnabled()
+ const isTranscriptEnabled = useIsRecordingModeEnabled(
+ RecordingMode.Transcript
+ )
if (isTranscriptOpen && isTranscriptEnabled) {
return <Transcript />
diff --git a/src/frontend/src/features/rooms/livekit/components/Transcript.tsx b/src/frontend/src/features/rooms/livekit/components/Transcript.tsx
index 31576309..c23c9b3d 100644
--- a/src/frontend/src/features/rooms/livekit/components/Transcript.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/Transcript.tsx
@@ -16,7 +16,7 @@ import { NotificationPayload } from '@/features/notifications/NotificationPayloa
import { NotificationType } from '@/features/notifications/NotificationType'
import { useSnapshot } from 'valtio/index'
import { RecordingStatus, recordingStore } from '@/stores/recording'
-import { useHasTranscriptAccess } from '../hooks/useHasTranscriptAccess'
+import { useHasRecordingAccess } from '../hooks/useHasScreenRecordingAccess'
import {
BETA_USERS_FORM_URL,
CRISP_HELP_ARTICLE_TRANSCRIPT,
@@ -26,7 +26,10 @@ export const Transcript = () => {
const [isLoading, setIsLoading] = useState(false)
const { t } = useTranslation('rooms', { keyPrefix: 'transcript' })
- const hasTranscriptAccess = useHasTranscriptAccess()
+ const hasTranscriptAccess = useHasRecordingAccess(
+ RecordingMode.Transcript,
+ 'transcription-summary'
+ )
const roomId = useRoomId()
const { mutateAsync: startRecordingRoom } = useStartRecording()
diff --git a/src/frontend/src/features/rooms/livekit/hooks/useHasTranscriptAccess.ts b/src/frontend/src/features/rooms/livekit/hooks/useHasScreenRecordingAccess.ts
similarity index 50%
rename from src/frontend/src/features/rooms/livekit/hooks/useHasTranscriptAccess.ts
rename to src/frontend/src/features/rooms/livekit/hooks/useHasScreenRecordingAccess.ts
index 731ba0ba..0f578b2e 100644
--- a/src/frontend/src/features/rooms/livekit/hooks/useHasTranscriptAccess.ts
+++ b/src/frontend/src/features/rooms/livekit/hooks/useHasScreenRecordingAccess.ts
@@ -1,17 +1,21 @@
import { useFeatureFlagEnabled } from 'posthog-js/react'
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
-import { useIsTranscriptEnabled } from './useIsTranscriptEnabled'
+import { RecordingMode } from '@/features/rooms/api/startRecording'
+import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
import { useIsAdminOrOwner } from './useIsAdminOrOwner'
-export const useHasTranscriptAccess = () => {
- const featureEnabled = useFeatureFlagEnabled('transcription-summary')
+export const useHasRecordingAccess = (
+ mode: RecordingMode,
+ featureFlag: string
+) => {
+ const featureEnabled = useFeatureFlagEnabled(featureFlag)
const isAnalyticsEnabled = useIsAnalyticsEnabled()
- const isTranscriptEnabled = useIsTranscriptEnabled()
+ const isRecordingModeEnabled = useIsRecordingModeEnabled(mode)
const isAdminOrOwner = useIsAdminOrOwner()
return (
(featureEnabled || !isAnalyticsEnabled) &&
isAdminOrOwner &&
- isTranscriptEnabled
+ isRecordingModeEnabled
)
}
diff --git a/src/frontend/src/features/rooms/livekit/hooks/useIsTranscriptEnabled.ts b/src/frontend/src/features/rooms/livekit/hooks/useIsRecordingModeEnabled.ts
similarity index 61%
rename from src/frontend/src/features/rooms/livekit/hooks/useIsTranscriptEnabled.ts
rename to src/frontend/src/features/rooms/livekit/hooks/useIsRecordingModeEnabled.ts
index 085538e4..d94772c0 100644
--- a/src/frontend/src/features/rooms/livekit/hooks/useIsTranscriptEnabled.ts
+++ b/src/frontend/src/features/rooms/livekit/hooks/useIsRecordingModeEnabled.ts
@@ -1,11 +1,11 @@
import { RecordingMode } from '@/features/rooms/api/startRecording'
import { useConfig } from '@/api/useConfig'
-export const useIsTranscriptEnabled = () => {
+export const useIsRecordingModeEnabled = (mode: RecordingMode) => {
const { data } = useConfig()
return (
data?.recording?.is_enabled &&
- data?.recording?.available_modes?.includes(RecordingMode.Transcript)
+ data?.recording?.available_modes?.includes(mode)
)
}