mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-03 06:08:29 +00:00
♻️(frontend) move InviteDialog state down the React tree
The InviteDialog open state was managed very high in the React tree, which triggered a re-render of the whole conference tree whenever the dialog was opened or closed. Push the state down to a narrower component to limit the scope of re-renders. Part of a broader effort to isolate as much as possible what should re-render, so we can then focus on tackling the real performance issues.
This commit is contained in:
committed by
aleb_the_flash
parent
63a7de402b
commit
8cd6496b5b
@@ -170,7 +170,6 @@ export const Conference = ({
|
|||||||
prepareConnection()
|
prepareConnection()
|
||||||
}, [room, apiConfig, isConnectionWarmedUp])
|
}, [room, apiConfig, isConnectionWarmedUp])
|
||||||
|
|
||||||
const [showInviteDialog, setShowInviteDialog] = useState(mode === 'create')
|
|
||||||
const [mediaDeviceError, setMediaDeviceError] = useState<{
|
const [mediaDeviceError, setMediaDeviceError] = useState<{
|
||||||
error: MediaDeviceFailure | null
|
error: MediaDeviceFailure | null
|
||||||
kind: MediaDeviceKind | null
|
kind: MediaDeviceKind | null
|
||||||
@@ -303,13 +302,7 @@ export const Conference = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<VideoConference />
|
<VideoConference />
|
||||||
{showInviteDialog && !isMobile && (
|
{!isMobile && <InviteDialog mode={mode} />}
|
||||||
<InviteDialog
|
|
||||||
isOpen={showInviteDialog}
|
|
||||||
onOpenChange={setShowInviteDialog}
|
|
||||||
onClose={() => setShowInviteDialog(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<MediaDeviceErrorAlert
|
<MediaDeviceErrorAlert
|
||||||
{...mediaDeviceError}
|
{...mediaDeviceError}
|
||||||
onClose={() => setMediaDeviceError({ error: null, kind: null })}
|
onClose={() => setMediaDeviceError({ error: null, kind: null })}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { getRouteUrl } from '@/navigation/getRouteUrl'
|
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 { HStack, styled, VStack } from '@/styled-system/jsx'
|
||||||
import { Heading, Dialog } from 'react-aria-components'
|
import { Heading, Dialog } from 'react-aria-components'
|
||||||
import { Text, text } from '@/primitives/Text'
|
import { Text, text } from '@/primitives/Text'
|
||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
RiFileCopyLine,
|
RiFileCopyLine,
|
||||||
RiSpam2Fill,
|
RiSpam2Fill,
|
||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import { useMemo } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { useRoomData } from '@/features/rooms/livekit/hooks/useRoomData'
|
import { useRoomData } from '@/features/rooms/livekit/hooks/useRoomData'
|
||||||
import { ApiAccessLevel } from '@/features/rooms/api/ApiRoom'
|
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 { t } = useTranslation('rooms', { keyPrefix: 'shareDialog' })
|
||||||
|
|
||||||
const roomData = useRoomData()
|
const roomData = useRoomData()
|
||||||
@@ -58,9 +60,9 @@ export const InviteDialog = (props: Omit<DialogProps, 'title'>) => {
|
|||||||
copyRoomUrlToClipboard,
|
copyRoomUrlToClipboard,
|
||||||
} = useCopyRoomToClipboard(roomData)
|
} = useCopyRoomToClipboard(roomData)
|
||||||
|
|
||||||
|
if (!showInviteDialog) return null
|
||||||
return (
|
return (
|
||||||
<StyledRACDialog {...props}>
|
<StyledRACDialog>
|
||||||
{({ close }) => (
|
|
||||||
<VStack
|
<VStack
|
||||||
alignItems="left"
|
alignItems="left"
|
||||||
justify="start"
|
justify="start"
|
||||||
@@ -76,8 +78,7 @@ export const InviteDialog = (props: Omit<DialogProps, 'title'>) => {
|
|||||||
variant="tertiaryText"
|
variant="tertiaryText"
|
||||||
size="xs"
|
size="xs"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
props.onClose?.()
|
setShowInviteDialog(false)
|
||||||
close()
|
|
||||||
}}
|
}}
|
||||||
aria-label={t('closeDialog')}
|
aria-label={t('closeDialog')}
|
||||||
>
|
>
|
||||||
@@ -214,7 +215,6 @@ export const InviteDialog = (props: Omit<DialogProps, 'title'>) => {
|
|||||||
</HStack>
|
</HStack>
|
||||||
)}
|
)}
|
||||||
</VStack>
|
</VStack>
|
||||||
)}
|
|
||||||
</StyledRACDialog>
|
</StyledRACDialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user