Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thecybernanny-webapp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
asranov0003
thecybernanny-webapp
Commits
a1c2997a
Commit
a1c2997a
authored
Jul 24, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: bug with fetching device list
parent
4aeea9b3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
Header.tsx
src/layouts/Header/Header.tsx
+5
-3
deviceSlice.ts
src/stores/slices/deviceSlice.ts
+5
-0
No files found.
src/layouts/Header/Header.tsx
View file @
a1c2997a
...
@@ -32,17 +32,19 @@ const Header: React.FC = () => {
...
@@ -32,17 +32,19 @@ const Header: React.FC = () => {
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
dispatch
=
useAppDispatch
();
const
dispatch
=
useAppDispatch
();
const
{
session
}
=
useAppSelector
((
state
:
RootState
)
=>
state
.
account
);
const
{
session
}
=
useAppSelector
((
state
:
RootState
)
=>
state
.
account
);
const
{
devices
,
selectedDevice
}
=
useAppSelector
(
const
{
devices
,
selectedDevice
,
isFetched
}
=
useAppSelector
(
(
state
:
RootState
)
=>
state
.
device
(
state
:
RootState
)
=>
state
.
device
);
);
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
accountSession
());
dispatch
(
accountSession
());
},
[
dispatch
]);
if
(
devices
.
length
===
0
)
{
useEffect
(()
=>
{
if
(
!
isFetched
)
{
dispatch
(
fetchDevices
());
dispatch
(
fetchDevices
());
}
}
},
[
dispatch
,
devices
]);
},
[
dispatch
,
isFetched
]);
const
handleOutsideClick
=
(
e
:
MouseEvent
)
=>
{
const
handleOutsideClick
=
(
e
:
MouseEvent
)
=>
{
if
(
sidebarRef
.
current
&&
!
sidebarRef
.
current
.
contains
(
e
.
target
as
Node
))
{
if
(
sidebarRef
.
current
&&
!
sidebarRef
.
current
.
contains
(
e
.
target
as
Node
))
{
...
...
src/stores/slices/deviceSlice.ts
View file @
a1c2997a
...
@@ -17,6 +17,7 @@ interface IDeviceState {
...
@@ -17,6 +17,7 @@ interface IDeviceState {
selectedDevice
:
IDevice
|
null
;
selectedDevice
:
IDevice
|
null
;
loadingDevices
:
boolean
;
loadingDevices
:
boolean
;
errorDevices
:
string
;
errorDevices
:
string
;
isFetched
:
boolean
}
}
const
initialState
:
IDeviceState
=
{
const
initialState
:
IDeviceState
=
{
...
@@ -25,6 +26,7 @@ const initialState: IDeviceState = {
...
@@ -25,6 +26,7 @@ const initialState: IDeviceState = {
selectedDevice
:
null
,
selectedDevice
:
null
,
loadingDevices
:
false
,
loadingDevices
:
false
,
errorDevices
:
""
,
errorDevices
:
""
,
isFetched
:
false
};
};
export
const
fetchDevices
=
createAsyncThunk
(
export
const
fetchDevices
=
createAsyncThunk
(
...
@@ -81,15 +83,18 @@ const deviceSlice = createSlice({
...
@@ -81,15 +83,18 @@ const deviceSlice = createSlice({
builder
builder
.
addCase
(
fetchDevices
.
pending
,
(
state
)
=>
{
.
addCase
(
fetchDevices
.
pending
,
(
state
)
=>
{
state
.
loadingDevices
=
true
;
state
.
loadingDevices
=
true
;
state
.
isFetched
=
false
;
})
})
.
addCase
(
fetchDevices
.
fulfilled
,
(
state
,
action
)
=>
{
.
addCase
(
fetchDevices
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
loadingDevices
=
false
;
state
.
loadingDevices
=
false
;
state
.
devices
=
action
.
payload
;
state
.
devices
=
action
.
payload
;
state
.
selectedDevice
=
action
.
payload
[
0
]
??
null
;
state
.
selectedDevice
=
action
.
payload
[
0
]
??
null
;
state
.
isFetched
=
true
;
})
})
.
addCase
(
fetchDevices
.
rejected
,
(
state
,
action
)
=>
{
.
addCase
(
fetchDevices
.
rejected
,
(
state
,
action
)
=>
{
state
.
loadingDevices
=
false
;
state
.
loadingDevices
=
false
;
state
.
errorDevices
=
action
.
payload
as
string
;
state
.
errorDevices
=
action
.
payload
as
string
;
state
.
isFetched
=
false
;
})
})
.
addCase
(
fetchDeviceData
.
fulfilled
,
(
state
,
action
)
=>
{
.
addCase
(
fetchDeviceData
.
fulfilled
,
(
state
,
action
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment