Skip to content

armgit / meet

Public Imported from GitHub
0

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

🚸(frontend) show support toggle only if support is enabled

lebaudantoine4ae3d965f982
diff --git a/src/frontend/src/features/rooms/livekit/components/controls/SupportToggle.tsx b/src/frontend/src/features/rooms/livekit/components/controls/SupportToggle.tsx
index 91042060..7e484564 100644
--- a/src/frontend/src/features/rooms/livekit/components/controls/SupportToggle.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/controls/SupportToggle.tsx
@@ -4,9 +4,11 @@ import { useTranslation } from 'react-i18next'
import { Crisp } from 'crisp-sdk-web'
import { useEffect, useState } from 'react'
import { ToggleButtonProps } from '@/primitives/ToggleButton'
+import { useIsSupportEnabled } from '@/features/support/hooks/useSupport'
export const SupportToggle = ({ onPress, ...props }: ToggleButtonProps) => {
const { t } = useTranslation('rooms', { keyPrefix: 'controls' })
+
const [isOpened, setIsOpened] = useState(() => {
return window?.$crisp?.is?.('chat:opened') || false
})
@@ -28,6 +30,12 @@ export const SupportToggle = ({ onPress, ...props }: ToggleButtonProps) => {
}
}, [])
+ const isSupportEnabled = useIsSupportEnabled()
+
+ if (!isSupportEnabled) {
+ return
+ }
+
return (
<ToggleButton
square
diff --git a/src/frontend/src/features/support/hooks/useSupport.tsx b/src/frontend/src/features/support/hooks/useSupport.tsx
index 3bff2a0d..9cbe94aa 100644
--- a/src/frontend/src/features/support/hooks/useSupport.tsx
+++ b/src/frontend/src/features/support/hooks/useSupport.tsx
@@ -1,6 +1,7 @@
import { useEffect } from 'react'
import { Crisp } from 'crisp-sdk-web'
import { ApiUser } from '@/features/auth/api/ApiUser'
+import { useConfig } from '@/api/useConfig'
export const initializeSupportSession = (user: ApiUser) => {
if (!Crisp.isCrispInjected()) return
@@ -29,3 +30,8 @@ export const useSupport = ({ id }: useSupportProps) => {
return null
}
+
+export const useIsSupportEnabled = () => {
+ const { data } = useConfig()
+ return !!data?.support?.id
+}