From aa117de647ff37ee5cf2ef29bc95a74975e039a4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 28 Jul 2026 10:00:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20extract=20closeS?= =?UTF-8?q?idePanel=20action=20at=20the=20store=20level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract the logic that closes the side panel into a utility function declared at the store module level, as recommended by Valtio. This avoids re-creating the function on every render and prevents extra re-renders in components that use it. --- .../src/features/rooms/livekit/components/SidePanel.tsx | 7 ++----- src/frontend/src/stores/layout.ts | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/components/SidePanel.tsx b/src/frontend/src/features/rooms/livekit/components/SidePanel.tsx index 67297a5e..9936dd05 100644 --- a/src/frontend/src/features/rooms/livekit/components/SidePanel.tsx +++ b/src/frontend/src/features/rooms/livekit/components/SidePanel.tsx @@ -1,4 +1,4 @@ -import { layoutStore } from '@/stores/layout' +import { closeSidePanel, layoutStore } from '@/stores/layout' import { css } from '@/styled-system/css' import { Heading } from 'react-aria-components' import { text } from '@/primitives/Text' @@ -199,10 +199,7 @@ export const SidePanel = () => { ref={asideRef} title={title} ariaLabel={t('ariaLabel', { title })} - onClose={() => { - layoutStore.activePanelId = null - layoutStore.activeSubPanelId = null - }} + onClose={closeSidePanel} closeButtonTooltip={t('closeButton', { content: t(`content.${activeSubPanelId || activePanelId}`), })} diff --git a/src/frontend/src/stores/layout.ts b/src/frontend/src/stores/layout.ts index 74bb52e9..44fea86d 100644 --- a/src/frontend/src/stores/layout.ts +++ b/src/frontend/src/stores/layout.ts @@ -34,3 +34,8 @@ export const setPinnedTrack = (trackRef: TrackReferenceOrPlaceholder): void => { export const clearPinnedTrack = (): void => { layoutStore.pinnedTrackRef = undefined } + +export const closeSidePanel = (): void => { + layoutStore.activePanelId = null + layoutStore.activeSubPanelId = null +}