Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
92d8930a
Commit
92d8930a
authored
8 months ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
chore: avoid useless dispatch
parent
b0c29d71
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1241
3.1 Release
,
!1172
chore: avoid useless dispatch
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/Content/Content.tsx
+13
-4
13 additions, 4 deletions
src/components/Content/Content.tsx
src/components/Header/CozyBar.tsx
+1
-2
1 addition, 2 deletions
src/components/Header/CozyBar.tsx
src/components/Header/Header.tsx
+9
-4
9 additions, 4 deletions
src/components/Header/Header.tsx
with
23 additions
and
10 deletions
src/components/Content/Content.tsx
+
13
−
4
View file @
92d8930a
import
FeedbackModal
from
'
components/Feedback/FeedbackModal
'
import
{
ScreenType
}
from
'
enums
'
import
React
,
{
useEffect
}
from
'
react
'
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
import
{
changeScreenType
}
from
'
store/global/global.slice
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
store/hooks
'
import
'
./content.scss
'
...
...
@@ -10,6 +10,7 @@ const Content = ({ children }: { children: React.ReactNode }) => {
const
{
screenType
,
headerHeight
}
=
useAppSelector
(
state
=>
state
.
ecolyo
.
global
)
const
currentScreenType
=
useRef
(
screenType
)
const
cozyBarHeight
=
48
const
cozyNavHeight
=
56
...
...
@@ -21,16 +22,24 @@ const Content = ({ children }: { children: React.ReactNode }) => {
useEffect
(()
=>
{
function
handleResize
()
{
let
newScreenType
:
ScreenType
if
(
innerWidth
<=
768
)
{
dispatch
(
change
ScreenType
(
ScreenType
.
MOBILE
))
new
ScreenType
=
ScreenType
.
MOBILE
}
else
if
(
innerWidth
<=
1024
)
{
dispatch
(
change
ScreenType
(
ScreenType
.
TABLET
))
new
ScreenType
=
ScreenType
.
TABLET
}
else
{
dispatch
(
changeScreenType
(
ScreenType
.
DESKTOP
))
newScreenType
=
ScreenType
.
DESKTOP
}
if
(
currentScreenType
.
current
!==
newScreenType
)
{
currentScreenType
.
current
=
newScreenType
dispatch
(
changeScreenType
(
newScreenType
))
}
}
handleResize
()
window
.
addEventListener
(
'
resize
'
,
handleResize
)
return
()
=>
{
window
.
removeEventListener
(
'
resize
'
,
handleResize
)
}
...
...
This diff is collapsed.
Click to expand it.
src/components/Header/CozyBar.tsx
+
1
−
2
View file @
92d8930a
...
...
@@ -68,9 +68,8 @@ const CozyBar = ({
</
BarRight
>
</>
)
}
else
{
return
null
}
return
null
}
export
default
CozyBar
This diff is collapsed.
Click to expand it.
src/components/Header/Header.tsx
+
9
−
4
View file @
92d8930a
...
...
@@ -29,7 +29,9 @@ const Header = ({
const
navigate
=
useNavigate
()
const
header
=
useRef
<
HTMLDivElement
>
(
null
)
const
dispatch
=
useAppDispatch
()
const
{
screenType
}
=
useAppSelector
(
state
=>
state
.
ecolyo
.
global
)
const
{
screenType
,
headerHeight
}
=
useAppSelector
(
state
=>
state
.
ecolyo
.
global
)
const
cozyBarHeight
=
48
const
handleClickBack
=
useCallback
(()
=>
{
...
...
@@ -45,10 +47,13 @@ const Header = ({
}
useEffect
(()
=>
{
const
header
Height
=
header
.
current
?.
clientHeight
||
0
const
ref
Height
=
header
.
current
?.
clientHeight
||
0
const
adjustment
=
screenType
===
ScreenType
.
MOBILE
?
cozyBarHeight
:
0
dispatch
(
setHeaderHeight
(
headerHeight
-
adjustment
))
},
[
screenType
,
children
,
dispatch
])
const
targetHeight
=
refHeight
-
adjustment
if
(
targetHeight
!==
headerHeight
)
{
dispatch
(
setHeaderHeight
(
targetHeight
))
}
},
[
screenType
,
children
,
dispatch
,
headerHeight
])
return
(
<
header
ref
=
{
header
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment