mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-13 20:27:01 +00:00
♻️(frontend) move keyboard shortcut registration to a leaf
Move the keyboard shortcut registration down into the SettingsDialogProvider leaf component, so shortcut-related re-renders no longer bubble up and re-render the whole Videoconference component.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { isWeb } from '@livekit/components-core'
|
import { isWeb } from '@livekit/components-core'
|
||||||
import { Track } from 'livekit-client'
|
import { Track } from 'livekit-client'
|
||||||
import React, { useCallback, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import {
|
import {
|
||||||
ConnectionStateToast,
|
ConnectionStateToast,
|
||||||
RoomAudioRenderer,
|
RoomAudioRenderer,
|
||||||
@@ -13,9 +13,6 @@ import { ScreenShareErrorModal } from '../components/ScreenShareErrorModal'
|
|||||||
import { ConnectionObserver } from '../components/ConnectionObserver'
|
import { ConnectionObserver } from '../components/ConnectionObserver'
|
||||||
import { useRoomPageTitle } from '../hooks/useRoomPageTitle'
|
import { useRoomPageTitle } from '../hooks/useRoomPageTitle'
|
||||||
import { useNoiseReduction } from '../hooks/useNoiseReduction'
|
import { useNoiseReduction } from '../hooks/useNoiseReduction'
|
||||||
import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut'
|
|
||||||
import { useSettingsDialog } from '@/features/settings'
|
|
||||||
import { SettingsDialogExtendedKey } from '@/features/settings/type'
|
|
||||||
import { useVideoResolutionSubscription } from '../hooks/useVideoResolutionSubscription'
|
import { useVideoResolutionSubscription } from '../hooks/useVideoResolutionSubscription'
|
||||||
import { useSyncLiveKitMetadata } from '../hooks/useSyncLiveKitMetadata'
|
import { useSyncLiveKitMetadata } from '../hooks/useSyncLiveKitMetadata'
|
||||||
import { SettingsDialogProvider } from '@/features/settings/components/SettingsDialogProvider'
|
import { SettingsDialogProvider } from '@/features/settings/components/SettingsDialogProvider'
|
||||||
@@ -54,19 +51,9 @@ export interface VideoConferenceProps extends React.HTMLAttributes<HTMLDivElemen
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function VideoConference({ ...props }: VideoConferenceProps) {
|
export function VideoConference({ ...props }: VideoConferenceProps) {
|
||||||
const { toggleSettingsDialog } = useSettingsDialog()
|
|
||||||
|
|
||||||
useRoomPageTitle()
|
useRoomPageTitle()
|
||||||
useVideoResolutionSubscription()
|
useVideoResolutionSubscription()
|
||||||
useSyncLiveKitMetadata()
|
useSyncLiveKitMetadata()
|
||||||
|
|
||||||
useRegisterKeyboardShortcut({
|
|
||||||
id: 'open-shortcuts',
|
|
||||||
handler: useCallback(() => {
|
|
||||||
toggleSettingsDialog(SettingsDialogExtendedKey.SHORTCUTS)
|
|
||||||
}, [toggleSettingsDialog]),
|
|
||||||
})
|
|
||||||
|
|
||||||
useNoiseReduction()
|
useNoiseReduction()
|
||||||
|
|
||||||
const { isOpen: isPictureInPictureOpen } = usePictureInPicture()
|
const { isOpen: isPictureInPictureOpen } = usePictureInPicture()
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
import { SettingsDialogExtended } from './SettingsDialogExtended'
|
import { SettingsDialogExtended } from './SettingsDialogExtended'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
import { settingsStore } from '@/stores/settings'
|
import { settingsStore } from '@/stores/settings'
|
||||||
|
import {
|
||||||
|
SettingsDialogExtendedKey,
|
||||||
|
useSettingsDialog,
|
||||||
|
} from '@/features/settings'
|
||||||
|
import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut'
|
||||||
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
export const SettingsDialogProvider = () => {
|
export const SettingsDialogProvider = () => {
|
||||||
const { areSettingsOpen, defaultSelectedTab } = useSnapshot(settingsStore)
|
const { areSettingsOpen, defaultSelectedTab } = useSnapshot(settingsStore)
|
||||||
|
|
||||||
|
const { toggleSettingsDialog } = useSettingsDialog()
|
||||||
|
|
||||||
|
useRegisterKeyboardShortcut({
|
||||||
|
id: 'open-shortcuts',
|
||||||
|
handler: useCallback(() => {
|
||||||
|
toggleSettingsDialog(SettingsDialogExtendedKey.SHORTCUTS)
|
||||||
|
}, [toggleSettingsDialog]),
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsDialogExtended
|
<SettingsDialogExtended
|
||||||
isOpen={areSettingsOpen}
|
isOpen={areSettingsOpen}
|
||||||
|
|||||||
Reference in New Issue
Block a user