Skip to content

armgit / meet

Public Imported from GitHub
0

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

♻️(frontend) move InviteDialog state down the React tree

lebaudantoine8cd6496b5bcf
diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx
index a404ce3d..1e6d1f25 100644
--- a/src/frontend/src/features/rooms/components/Conference.tsx
+++ b/src/frontend/src/features/rooms/components/Conference.tsx
@@ -170,7 +170,6 @@ export const Conference = ({
prepareConnection()
}, [room, apiConfig, isConnectionWarmedUp])
- const [showInviteDialog, setShowInviteDialog] = useState(mode === 'create')
const [mediaDeviceError, setMediaDeviceError] = useState<{
error: MediaDeviceFailure | null
kind: MediaDeviceKind | null
@@ -303,13 +302,7 @@ export const Conference = ({
}}
>
<VideoConference />
- {showInviteDialog && !isMobile && (
- <InviteDialog
- isOpen={showInviteDialog}
- onOpenChange={setShowInviteDialog}
- onClose={() => setShowInviteDialog(false)}
- />
- )}
+ {!isMobile && <InviteDialog mode={mode} />}
<MediaDeviceErrorAlert
{...mediaDeviceError}
onClose={() => setMediaDeviceError({ error: null, kind: null })}
diff --git a/src/frontend/src/features/rooms/components/InviteDialog.tsx b/src/frontend/src/features/rooms/components/InviteDialog.tsx
index e1ff2ab8..06273ee7 100644
--- a/src/frontend/src/features/rooms/components/InviteDialog.tsx
+++ b/src/frontend/src/features/rooms/components/InviteDialog.tsx
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next'
import { getRouteUrl } from '@/navigation/getRouteUrl'
-import { Div, Button, type DialogProps, P, Bold } from '@/primitives'
+import { Div, Button, P, Bold } from '@/primitives'
import { HStack, styled, VStack } from '@/styled-system/jsx'
import { Heading, Dialog } from 'react-aria-components'
import { Text, text } from '@/primitives/Text'
@@ -10,7 +10,7 @@ import {
RiFileCopyLine,
RiSpam2Fill,
} from '@remixicon/react'
-import { useMemo } from 'react'
+import { useMemo, useState } from 'react'
import { css } from '@/styled-system/css'
import { useRoomData } from '@/features/rooms/livekit/hooks/useRoomData'
import { ApiAccessLevel } from '@/features/rooms/api/ApiRoom'
@@ -39,7 +39,9 @@ const StyledRACDialog = styled(Dialog, {
},
})
-export const InviteDialog = (props: Omit<DialogProps, 'title'>) => {
+export const InviteDialog = ({ mode }: { mode: 'join' | 'create' }) => {
+ const [showInviteDialog, setShowInviteDialog] = useState(mode === 'create')
+
const { t } = useTranslation('rooms', { keyPrefix: 'shareDialog' })
const roomData = useRoomData()
@@ -58,163 +60,161 @@ export const InviteDialog = (props: Omit<DialogProps, 'title'>) => {
copyRoomUrlToClipboard,
} = useCopyRoomToClipboard(roomData)
+ if (!showInviteDialog) return null
return (
- <StyledRACDialog {...props}>
- {({ close }) => (
- <VStack
- alignItems="left"
- justify="start"
- gap={0}
- style={{ maxWidth: '100%', overflow: 'visible' }}
- >
- <Heading slot="title" level={2} className={text({ variant: 'h2' })}>
- {t('heading')}
- </Heading>
- <Div position="absolute" top="5" right="5">
- <Button
- invisible
- variant="tertiaryText"
- size="xs"
- onPress={() => {
- props.onClose?.()
- close()
- }}
- aria-label={t('closeDialog')}
+ <StyledRACDialog>
+ <VStack
+ alignItems="left"
+ justify="start"
+ gap={0}
+ style={{ maxWidth: '100%', overflow: 'visible' }}
+ >
+ <Heading slot="title" level={2} className={text({ variant: 'h2' })}>
+ {t('heading')}
+ </Heading>
+ <Div position="absolute" top="5" right="5">
+ <Button
+ invisible
+ variant="tertiaryText"
+ size="xs"
+ onPress={() => {
+ setShowInviteDialog(false)
+ }}
+ aria-label={t('closeDialog')}
+ >
+ <RiCloseLine />
+ </Button>
+ </Div>
+ <P>{t('description')}</P>
+ {isTelephonyReadyForUse ? (
+ <div
+ className={css({
+ width: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ marginTop: '0.5rem',
+ gap: '1rem',
+ overflow: 'visible',
+ })}
+ >
+ <div
+ className={css({
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ })}
>
- <RiCloseLine />
- </Button>
- </Div>
- <P>{t('description')}</P>
- {isTelephonyReadyForUse ? (
+ <Text as="p" wrap="pretty">
+ {roomUrl?.replace(/^https?:\/\//, '')}
+ </Text>
+ {isTelephonyReadyForUse && roomUrl && (
+ <Button
+ variant={isRoomUrlCopied ? 'success' : 'tertiaryText'}
+ square
+ size={'sm'}
+ onPress={copyRoomUrlToClipboard}
+ aria-label={isRoomUrlCopied ? t('copied') : t('copyUrl')}
+ tooltip={isRoomUrlCopied ? t('copied') : t('copyUrl')}
+ >
+ {isRoomUrlCopied ? (
+ <RiCheckLine aria-hidden="true" />
+ ) : (
+ <RiFileCopyLine aria-hidden="true" />
+ )}
+ </Button>
+ )}
+ </div>
<div
className={css({
- width: '100%',
display: 'flex',
flexDirection: 'column',
- marginTop: '0.5rem',
- gap: '1rem',
- overflow: 'visible',
})}
>
- <div
- className={css({
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- })}
- >
- <Text as="p" wrap="pretty">
- {roomUrl?.replace(/^https?:\/\//, '')}
- </Text>
- {isTelephonyReadyForUse && roomUrl && (
- <Button
- variant={isRoomUrlCopied ? 'success' : 'tertiaryText'}
- square
- size={'sm'}
- onPress={copyRoomUrlToClipboard}
- aria-label={isRoomUrlCopied ? t('copied') : t('copyUrl')}
- tooltip={isRoomUrlCopied ? t('copied') : t('copyUrl')}
- >
- {isRoomUrlCopied ? (
- <RiCheckLine aria-hidden="true" />
- ) : (
- <RiFileCopyLine aria-hidden="true" />
- )}
- </Button>
- )}
- </div>
- <div
- className={css({
- display: 'flex',
- flexDirection: 'column',
- })}
- >
- <Text as="p" wrap="pretty">
- <Bold>{t('phone.call')}</Bold> ({telephony?.country}){' '}
- {telephony?.internationalPhoneNumber}
- </Text>
- <Text as="p" wrap="pretty">
- <Bold>{t('phone.pinCode')}</Bold>{' '}
- {formatPinCode(roomData?.pin_code)}
- </Text>
- </div>
-
- <Button
- variant={isCopied ? 'success' : 'secondaryText'}
- size="sm"
- fullWidth
- aria-label={isCopied ? t('copied') : t('copy')}
- style={{
- justifyContent: 'start',
- }}
- onPress={copyRoomToClipboard}
- data-attr="share-dialog-copy"
- >
- {isCopied ? (
- <>
- <RiCheckLine
- size={18}
- style={{ marginRight: '8px' }}
- aria-hidden="true"
- />
- {t('copied')}
- </>
- ) : (
- <>
- <RiFileCopyLine
- style={{ marginRight: '6px', minWidth: '18px' }}
- aria-hidden="true"
- />
- {t('copy')}
- </>
- )}
- </Button>
+ <Text as="p" wrap="pretty">
+ <Bold>{t('phone.call')}</Bold> ({telephony?.country}){' '}
+ {telephony?.internationalPhoneNumber}
+ </Text>
+ <Text as="p" wrap="pretty">
+ <Bold>{t('phone.pinCode')}</Bold>{' '}
+ {formatPinCode(roomData?.pin_code)}
+ </Text>
</div>
- ) : (
+
<Button
- variant={isCopied ? 'success' : 'tertiary'}
+ variant={isCopied ? 'success' : 'secondaryText'}
+ size="sm"
fullWidth
aria-label={isCopied ? t('copied') : t('copy')}
+ style={{
+ justifyContent: 'start',
+ }}
onPress={copyRoomToClipboard}
data-attr="share-dialog-copy"
>
{isCopied ? (
<>
- <RiCheckLine size={24} style={{ marginRight: '8px' }} />
+ <RiCheckLine
+ size={18}
+ style={{ marginRight: '8px' }}
+ aria-hidden="true"
+ />
{t('copied')}
</>
) : (
<>
- <RiFileCopyLine size={24} style={{ marginRight: '8px' }} />
- {t('copyUrl')}
+ <RiFileCopyLine
+ style={{ marginRight: '6px', minWidth: '18px' }}
+ aria-hidden="true"
+ />
+ {t('copy')}
</>
)}
</Button>
- )}
- {roomData?.access_level === ApiAccessLevel.PUBLIC && (
- <HStack>
- <div
+ </div>
+ ) : (
+ <Button
+ variant={isCopied ? 'success' : 'tertiary'}
+ fullWidth
+ aria-label={isCopied ? t('copied') : t('copy')}
+ onPress={copyRoomToClipboard}
+ data-attr="share-dialog-copy"
+ >
+ {isCopied ? (
+ <>
+ <RiCheckLine size={24} style={{ marginRight: '8px' }} />
+ {t('copied')}
+ </>
+ ) : (
+ <>
+ <RiFileCopyLine size={24} style={{ marginRight: '8px' }} />
+ {t('copyUrl')}
+ </>
+ )}
+ </Button>
+ )}
+ {roomData?.access_level === ApiAccessLevel.PUBLIC && (
+ <HStack>
+ <div
+ className={css({
+ backgroundColor: 'primary.200',
+ borderRadius: '50%',
+ padding: '4px',
+ marginTop: '1rem',
+ })}
+ >
+ <RiSpam2Fill
+ size={22}
className={css({
- backgroundColor: 'primary.200',
- borderRadius: '50%',
- padding: '4px',
- marginTop: '1rem',
+ fill: 'primary.500',
})}
- >
- <RiSpam2Fill
- size={22}
- className={css({
- fill: 'primary.500',
- })}
- />
- </div>
- <Text variant="sm" style={{ marginTop: '1rem' }}>
- {t('permissions')}
- </Text>
- </HStack>
- )}
- </VStack>
- )}
+ />
+ </div>
+ <Text variant="sm" style={{ marginTop: '1rem' }}>
+ {t('permissions')}
+ </Text>
+ </HStack>
+ )}
+ </VStack>
</StyledRACDialog>
)
}