🔌 AirDCPP socket refactoring
This commit is contained in:
3
.babelrc
3
.babelrc
@@ -7,7 +7,8 @@
|
|||||||
"plugins": [
|
"plugins": [
|
||||||
"react-hot-loader/babel",
|
"react-hot-loader/babel",
|
||||||
"@babel/transform-runtime",
|
"@babel/transform-runtime",
|
||||||
"@babel/plugin-proposal-class-properties"
|
"@babel/plugin-proposal-class-properties",
|
||||||
|
"@babel/plugin-syntax-top-level-await"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"production": {
|
"production": {
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.13.10",
|
"@babel/cli": "^7.13.10",
|
||||||
"@babel/core": "^7.13.10",
|
"@babel/core": "^7.13.10",
|
||||||
|
"@babel/plugin-syntax-top-level-await": "^7.14.5",
|
||||||
"@babel/plugin-transform-runtime": "^7.13.15",
|
"@babel/plugin-transform-runtime": "^7.13.15",
|
||||||
"@babel/preset-env": "^7.13.10",
|
"@babel/preset-env": "^7.13.10",
|
||||||
"@babel/preset-react": "^7.12.13",
|
"@babel/preset-react": "^7.12.13",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, ReactElement } from "react";
|
import React, { useCallback, useEffect, useState, ReactElement } from "react";
|
||||||
import {
|
import {
|
||||||
search,
|
search,
|
||||||
downloadAirDCPPItem,
|
downloadAirDCPPItem,
|
||||||
@@ -7,8 +7,9 @@ import {
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { RootState, SearchInstance } from "threetwo-ui-typings";
|
import { RootState, SearchInstance } from "threetwo-ui-typings";
|
||||||
import ellipsize from "ellipsize";
|
import ellipsize from "ellipsize";
|
||||||
import { isEmpty, isNil, map } from "lodash";
|
import { isEmpty, isNil, isUndefined, map } from "lodash";
|
||||||
|
import { getSettings } from "../actions/settings.actions";
|
||||||
|
import AirDCPPSocket from "../services/DcppSearchService";
|
||||||
interface IAcquisitionPanelProps {
|
interface IAcquisitionPanelProps {
|
||||||
comicBookMetadata: any;
|
comicBookMetadata: any;
|
||||||
}
|
}
|
||||||
@@ -20,6 +21,10 @@ export const AcquisitionPanel = (
|
|||||||
props.comicBookMetadata.sourcedMetadata.comicvine.volumeInformation.name;
|
props.comicBookMetadata.sourcedMetadata.comicvine.volumeInformation.name;
|
||||||
const sanitizedVolumeName = volumeName.replace(/[^a-zA-Z0-9 ]/g, "");
|
const sanitizedVolumeName = volumeName.replace(/[^a-zA-Z0-9 ]/g, "");
|
||||||
const issueName = props.comicBookMetadata.sourcedMetadata.comicvine.name;
|
const issueName = props.comicBookMetadata.sourcedMetadata.comicvine.name;
|
||||||
|
|
||||||
|
// local state
|
||||||
|
const [ADCPPSocket, setADCPPSocket] = useState({});
|
||||||
|
// Selectors for picking state
|
||||||
const airDCPPSearchResults = useSelector((state: RootState) => {
|
const airDCPPSearchResults = useSelector((state: RootState) => {
|
||||||
return state.airdcpp.searchResults;
|
return state.airdcpp.searchResults;
|
||||||
});
|
});
|
||||||
@@ -32,8 +37,22 @@ export const AcquisitionPanel = (
|
|||||||
const searchInstance: SearchInstance = useSelector(
|
const searchInstance: SearchInstance = useSelector(
|
||||||
(state: RootState) => state.airdcpp.searchInstance,
|
(state: RootState) => state.airdcpp.searchInstance,
|
||||||
);
|
);
|
||||||
|
const airDCPPClientSettings = useSelector(
|
||||||
|
(state: RootState) => state.settings.data,
|
||||||
|
);
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(getSettings());
|
||||||
|
if (!isUndefined(airDCPPClientSettings[0])) {
|
||||||
|
const dcppSocket = new AirDCPPSocket({
|
||||||
|
hostname: `${airDCPPClientSettings[0].directConnect.client.hostname}`,
|
||||||
|
});
|
||||||
|
setADCPPSocket(dcppSocket);
|
||||||
|
}
|
||||||
|
}, [dispatch, airDCPPClientSettings.length]);
|
||||||
|
|
||||||
|
console.log(ADCPPSocket);
|
||||||
const getDCPPSearchResults = useCallback(
|
const getDCPPSearchResults = useCallback(
|
||||||
(searchQuery) => {
|
(searchQuery) => {
|
||||||
dispatch(search(searchQuery));
|
dispatch(search(searchQuery));
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ export const AirDCPPSettingsForm = (): ReactElement => {
|
|||||||
<p className="control">
|
<p className="control">
|
||||||
<span className="select">
|
<span className="select">
|
||||||
<Field name="protocol" component="select">
|
<Field name="protocol" component="select">
|
||||||
<option value="http://">http://</option>
|
<option value="http://" defaultValue={"http://"}>
|
||||||
|
http://
|
||||||
|
</option>
|
||||||
<option value="https://">https://</option>
|
<option value="https://">https://</option>
|
||||||
</Field>
|
</Field>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -54,5 +54,20 @@
|
|||||||
"displayName": "Options"
|
"displayName": "Options"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"category": "acknowledgments",
|
||||||
|
"displayName": "Acknowledgments",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"id": "testers",
|
||||||
|
"displayName": "Testers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "software",
|
||||||
|
"displayName": "Software"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import { Socket } from "airdcpp-apisocket";
|
import { Socket } from "airdcpp-apisocket";
|
||||||
|
|
||||||
const options = {
|
class AirDCPPSocket {
|
||||||
url: "wss://sab.rishighan.com/api/v1/",
|
constructor(configuration) {
|
||||||
autoReconnect: false,
|
const options = {
|
||||||
reconnectInterval: 5,
|
url: `wss://${configuration.hostname}/api/v1/`,
|
||||||
logLevel: "verbose",
|
autoReconnect: false,
|
||||||
ignoredListenerEvents: [
|
reconnectInterval: 5,
|
||||||
"transfer_statistics",
|
logLevel: "verbose",
|
||||||
"hash_statistics",
|
ignoredListenerEvents: [
|
||||||
"hub_counts_updated",
|
"transfer_statistics",
|
||||||
],
|
"hash_statistics",
|
||||||
};
|
"hub_counts_updated",
|
||||||
|
],
|
||||||
const APISocket = Socket(options, window.WebSocket as any);
|
};
|
||||||
type SocketType = typeof APISocket;
|
const AirDCPPSocketInstance = Socket(options, window.WebSocket as any);
|
||||||
export { SocketType as APISocket };
|
return AirDCPPSocketInstance;
|
||||||
|
}
|
||||||
export default APISocket;
|
}
|
||||||
|
export default AirDCPPSocket;
|
||||||
|
|||||||
@@ -11,12 +11,7 @@
|
|||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"lib": [
|
"lib": ["dom", "dom.iterable", "esnext", "webworker"]
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext",
|
|
||||||
"webworker"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": [
|
||||||
@@ -26,11 +21,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["./src/server "],
|
||||||
"./src/server "
|
"include": ["./src/client/*", "./src/client/types/**/*.d.ts"]
|
||||||
],
|
}
|
||||||
"include": [
|
|
||||||
"./src/client/*",
|
|
||||||
"./src/client/types/**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ module.exports = () => {
|
|||||||
stats: {
|
stats: {
|
||||||
children: true,
|
children: true,
|
||||||
},
|
},
|
||||||
|
experiments: {
|
||||||
|
topLevelAwait: true,
|
||||||
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user