mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-31 04:37:57 +00:00
♻️(frontend) extract closeSidePanel action at the store level
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.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { layoutStore } from '@/stores/layout'
|
import { closeSidePanel, layoutStore } from '@/stores/layout'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { Heading } from 'react-aria-components'
|
import { Heading } from 'react-aria-components'
|
||||||
import { text } from '@/primitives/Text'
|
import { text } from '@/primitives/Text'
|
||||||
@@ -199,10 +199,7 @@ export const SidePanel = () => {
|
|||||||
ref={asideRef}
|
ref={asideRef}
|
||||||
title={title}
|
title={title}
|
||||||
ariaLabel={t('ariaLabel', { title })}
|
ariaLabel={t('ariaLabel', { title })}
|
||||||
onClose={() => {
|
onClose={closeSidePanel}
|
||||||
layoutStore.activePanelId = null
|
|
||||||
layoutStore.activeSubPanelId = null
|
|
||||||
}}
|
|
||||||
closeButtonTooltip={t('closeButton', {
|
closeButtonTooltip={t('closeButton', {
|
||||||
content: t(`content.${activeSubPanelId || activePanelId}`),
|
content: t(`content.${activeSubPanelId || activePanelId}`),
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -34,3 +34,8 @@ export const setPinnedTrack = (trackRef: TrackReferenceOrPlaceholder): void => {
|
|||||||
export const clearPinnedTrack = (): void => {
|
export const clearPinnedTrack = (): void => {
|
||||||
layoutStore.pinnedTrackRef = undefined
|
layoutStore.pinnedTrackRef = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const closeSidePanel = (): void => {
|
||||||
|
layoutStore.activePanelId = null
|
||||||
|
layoutStore.activeSubPanelId = null
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user