🔧 Updated AirDC++ socket connection code app-wide

This commit is contained in:
2023-01-20 21:55:41 -08:00
parent 3102b489c8
commit 1d8dd3ca3e
4 changed files with 6 additions and 22 deletions

View File

@@ -64,11 +64,7 @@ export const search =
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect(
credentials.username,
credentials.password,
true,
);
await ADCPPSocket();
}
const instance: SearchInstance = await ADCPPSocket.post("search");
dispatch({
@@ -154,11 +150,7 @@ export const downloadAirDCPPItem =
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
await ADCPPSocket.connect();
}
let bundleDBImportResult = {};
const downloadResult = await ADCPPSocket.post(
@@ -203,11 +195,7 @@ export const getBundlesForComic =
async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
await ADCPPSocket.connect();
}
const comicObject = await axios({
method: "POST",
@@ -241,11 +229,7 @@ export const getTransfers =
(ADCPPSocket: any, credentials: any) => async (dispatch) => {
try {
if (!ADCPPSocket.isConnected()) {
await ADCPPSocket.connect(
`${credentials.username}`,
`${credentials.password}`,
true,
);
await ADCPPSocket.connect();
}
const bundles = await ADCPPSocket.get("queue/bundles/1/85", {});
if (!isNil(bundles)) {

View File

@@ -20,7 +20,6 @@ const Navbar: React.FunctionComponent = (props) => {
const socketDisconnectionReason = useSelector(
(state: RootState) => state.airdcpp.socketDisconnectionReason,
);
return (
<nav className="navbar is-fixed-top">
<div className="navbar-brand">

View File

@@ -116,6 +116,7 @@ function airdcppReducer(state = initialState, action) {
};
case LOCATION_CHANGE:
return {
...state,
searchResults: [],
isAirDCPPSearchInProgress: false,
searchInfo: null,

View File

@@ -18,7 +18,7 @@ function sleep(ms: number): Promise<NodeJS.Timeout> {
}
export const search = async (data: SearchData) => {
await SocketService.connect("admin", "password");
await SocketService.connect();
const instance: SearchInstance = await SocketService.post("search");
const unsubscribe = await SocketService.addListener(
"search",