Skip to content
Snippets Groups Projects
Commit df5af83c authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Revert "chore(ui): avoid useless dispatch"

This reverts commit 3acf0e28.
parent 0f817e39
Branches
Tags
1 merge request!11623.0 Release
...@@ -21,11 +21,11 @@ const Content = ({ children }: { children: React.ReactNode }) => { ...@@ -21,11 +21,11 @@ const Content = ({ children }: { children: React.ReactNode }) => {
useEffect(() => { useEffect(() => {
function handleResize() { function handleResize() {
if (innerWidth <= 768 && screenType !== ScreenType.MOBILE) { if (innerWidth <= 768) {
dispatch(changeScreenType(ScreenType.MOBILE)) dispatch(changeScreenType(ScreenType.MOBILE))
} else if (innerWidth <= 1024 && screenType !== ScreenType.TABLET) { } else if (innerWidth <= 1024) {
dispatch(changeScreenType(ScreenType.TABLET)) dispatch(changeScreenType(ScreenType.TABLET))
} else if (innerWidth > 1024 && screenType !== ScreenType.DESKTOP) { } else {
dispatch(changeScreenType(ScreenType.DESKTOP)) dispatch(changeScreenType(ScreenType.DESKTOP))
} }
} }
...@@ -34,7 +34,7 @@ const Content = ({ children }: { children: React.ReactNode }) => { ...@@ -34,7 +34,7 @@ const Content = ({ children }: { children: React.ReactNode }) => {
return () => { return () => {
window.removeEventListener('resize', handleResize) window.removeEventListener('resize', handleResize)
} }
}, [dispatch, screenType]) }, [dispatch])
return ( return (
<> <>
......
...@@ -68,8 +68,9 @@ const CozyBar = ({ ...@@ -68,8 +68,9 @@ const CozyBar = ({
</BarRight> </BarRight>
</> </>
) )
} else {
return null
} }
return null
} }
export default CozyBar export default CozyBar
...@@ -31,9 +31,7 @@ const Header = ({ ...@@ -31,9 +31,7 @@ const Header = ({
const navigate = useNavigate() const navigate = useNavigate()
const header = useRef<HTMLDivElement>(null) const header = useRef<HTMLDivElement>(null)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const { screenType, headerHeight } = useAppSelector( const { screenType } = useAppSelector(state => state.ecolyo.global)
state => state.ecolyo.global
)
const cozyBarHeight = 48 const cozyBarHeight = 48
const handleClickBack = useCallback(() => { const handleClickBack = useCallback(() => {
...@@ -49,12 +47,10 @@ const Header = ({ ...@@ -49,12 +47,10 @@ const Header = ({
} }
useEffect(() => { useEffect(() => {
const refHeight = header.current?.clientHeight || 0 const headerHeight = header.current?.clientHeight || 0
const adjustment = screenType === ScreenType.MOBILE ? cozyBarHeight : 0 const adjustment = screenType === ScreenType.MOBILE ? cozyBarHeight : 0
const targetHeight = refHeight - adjustment dispatch(setHeaderHeight(headerHeight - adjustment))
if (targetHeight === headerHeight) return }, [screenType, children, dispatch])
dispatch(setHeaderHeight(targetHeight))
}, [screenType, children, dispatch, headerHeight])
return ( return (
<header ref={header}> <header ref={header}>
......
export enum ScreenType { export enum ScreenType {
MOBILE = 'MOBILE', MOBILE = 0,
TABLET = 'TABLET', TABLET = 1,
DESKTOP = 'DESKTOP', DESKTOP = 2,
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment