📥 Refactoring download tick panel

This commit is contained in:
2022-06-23 11:11:45 -07:00
parent d2dbb133b3
commit 2dea9e1096
6 changed files with 36 additions and 40 deletions

View File

@@ -21,11 +21,13 @@ import {
AirDCPPSocketContext,
} from "../context/AirDCPPSocket";
import { isEmpty, isUndefined } from "lodash";
import { AIRDCPP_DOWNLOAD_PROGRESS_TICK } from "../constants/action-types";
import { useDispatch } from "react-redux";
const AirDCPPSocketComponent = (): ReactElement => {
const airDCPPConfiguration = useContext(AirDCPPSocketContext);
console.log(airDCPPConfiguration);
const dispatch = useDispatch();
useEffect(() => {
const foo = async () => {
if (
@@ -38,6 +40,20 @@ const AirDCPPSocketComponent = (): ReactElement => {
"queue_bundle_added",
async (data) => console.log("JEMEN:", data),
);
// download tick listener
await airDCPPConfiguration.airDCPPState.socket.addListener(
`queue`,
"queue_bundle_tick",
async (downloadProgressData) => {
dispatch({
type: AIRDCPP_DOWNLOAD_PROGRESS_TICK,
downloadProgressData,
});
},
);
console.log(
"[AirDCPP]: Listener registered - listening to queue bundle download ticks",
);
console.log(
"[AirDCPP]: Listener registered - listening to queue bundle changes",
);