Open source video conferencing app powered by LiveKit. Built with Django and React.
♻️(frontend) encapsulate side panel values
lebaudantoine0da8aa846a97
diff --git a/src/frontend/src/features/rooms/livekit/hooks/useWidgetInteraction.ts b/src/frontend/src/features/rooms/livekit/hooks/useWidgetInteraction.tsindex 19f2af07..b886ddfd 100644--- a/src/frontend/src/features/rooms/livekit/hooks/useWidgetInteraction.ts+++ b/src/frontend/src/features/rooms/livekit/hooks/useWidgetInteraction.ts@@ -2,20 +2,25 @@ import { useLayoutContext } from '@livekit/components-react'import { useSnapshot } from 'valtio'import { layoutStore } from '@/stores/layout'+export enum SidePanel {+ PARTICIPANTS = 'participants',+ EFFECTS = 'effects',+}+export const useWidgetInteraction = () => {const { dispatch, state } = useLayoutContext().widgetconst layoutSnap = useSnapshot(layoutStore)const sidePanel = layoutSnap.sidePanel- const isParticipantsOpen = sidePanel == 'participants'- const isEffectsOpen = sidePanel == 'effects'+ const isParticipantsOpen = sidePanel == SidePanel.PARTICIPANTS+ const isEffectsOpen = sidePanel == SidePanel.EFFECTSconst toggleParticipants = () => {if (dispatch && state?.showChat) {dispatch({ msg: 'toggle_chat' })}- layoutStore.sidePanel = isParticipantsOpen ? null : 'participants'+ layoutStore.sidePanel = isParticipantsOpen ? null : SidePanel.PARTICIPANTS}const toggleChat = () => {@@ -31,7 +36,7 @@ export const useWidgetInteraction = () => {if (dispatch && state?.showChat) {dispatch({ msg: 'toggle_chat' })}- layoutStore.sidePanel = isEffectsOpen ? null : 'effects'+ layoutStore.sidePanel = isEffectsOpen ? null : SidePanel.EFFECTS}return {diff --git a/src/frontend/src/stores/layout.ts b/src/frontend/src/stores/layout.tsindex f8f42994..1dbf9e9f 100644--- a/src/frontend/src/stores/layout.ts+++ b/src/frontend/src/stores/layout.ts@@ -1,8 +1,9 @@import { proxy } from 'valtio'+import { SidePanel } from '@/features/rooms/livekit/hooks/useWidgetInteraction'type State = {showHeader: boolean- sidePanel: 'participants' | 'effects' | null+ sidePanel: SidePanel | null}export const layoutStore = proxy<State>({