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
0b3b7371
Commit
0b3b7371
authored
Jul 30, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add fetch audio files logic
parent
7a3d50d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
2 deletions
+53
-2
deviceSlice.ts
src/stores/slices/deviceSlice.ts
+53
-2
No files found.
src/stores/slices/deviceSlice.ts
View file @
0b3b7371
...
...
@@ -15,6 +15,8 @@ interface IDeviceState {
devices
:
IDevice
[];
deviceData
:
IDeviceData
|
null
;
selectedDevice
:
IDevice
|
null
;
audioList
:
any
[];
isAudioListLoading
:
boolean
;
loadingDevices
:
boolean
;
errorDevices
:
string
;
isFetched
:
boolean
;
...
...
@@ -25,6 +27,8 @@ const initialState: IDeviceState = {
devices
:
[],
deviceData
:
null
,
selectedDevice
:
null
,
audioList
:
[],
isAudioListLoading
:
false
,
loadingDevices
:
false
,
errorDevices
:
""
,
isFetched
:
false
,
...
...
@@ -72,6 +76,43 @@ export const fetchDeviceData = createAsyncThunk(
}
);
export
const
fetchAudioFiles
=
createAsyncThunk
(
"device/fetchAudioFiles"
,
async
(
{
deviceId
,
dateFrom
,
dateTo
,
appId
,
}:
{
deviceId
:
string
;
dateFrom
:
Date
;
dateTo
:
Date
;
appId
:
number
;
},
{
rejectWithValue
}
)
=>
{
try
{
const
response
=
await
sendRpcRequest
<
{
list
:
any
[]
}
>
(
"data.getMedia"
,
{
deviceId
,
type
:
appId
,
dateFrom
,
dateTo
,
recStart
:
0
,
recLimit
:
50
,
});
return
response
.
list
;
}
catch
(
error
:
unknown
)
{
if
(
typeof
error
===
"object"
&&
error
!==
null
&&
"message"
in
error
)
{
return
rejectWithValue
(
error
.
message
);
}
return
rejectWithValue
(
"Unknown error occurred"
);
}
}
);
export
const
deleteDevice
=
createAsyncThunk
(
"device/deleteDevice"
,
async
(
deviceId
:
string
,
{
rejectWithValue
})
=>
{
...
...
@@ -81,8 +122,6 @@ export const deleteDevice = createAsyncThunk(
{
deviceId
}
);
console
.
log
(
response
);
if
(
response
.
success
)
{
fetchDevices
();
}
...
...
@@ -140,6 +179,18 @@ const deviceSlice = createSlice({
.
addCase
(
deleteDevice
.
rejected
,
(
state
,
action
)
=>
{
state
.
isDeletingDevice
=
false
;
console
.
error
(
"Error deleting device:"
,
action
.
payload
);
})
.
addCase
(
fetchAudioFiles
.
pending
,
(
state
)
=>
{
state
.
isAudioListLoading
=
true
;
})
.
addCase
(
fetchAudioFiles
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
isAudioListLoading
=
false
;
state
.
audioList
=
action
.
payload
;
})
.
addCase
(
fetchAudioFiles
.
rejected
,
(
state
,
action
)
=>
{
state
.
isAudioListLoading
=
false
;
console
.
error
(
"Error fetching audio files:"
,
action
.
payload
);
});
},
});
...
...
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