From 5d430504ec4388cc4afc4f8e574f56638784d1cf Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Fri, 18 Oct 2024 13:18:59 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixing=20the=20DC++=20download?= =?UTF-8?q?=20bundles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComicDetail/AcquisitionPanel.tsx | 239 +++++++++--------- src/client/components/shared/Carda.tsx | 2 +- 2 files changed, 118 insertions(+), 123 deletions(-) diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 88c24d4..e21c01a 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -1,5 +1,4 @@ import React, { useCallback, ReactElement, useEffect, useState } from "react"; -import { getBundlesForComic, sleep } from "../../actions/airdcpp.actions"; import { SearchQuery, PriorityEnum, SearchResponse } from "threetwo-ui-typings"; import { RootState, SearchInstance } from "threetwo-ui-typings"; import ellipsize from "ellipsize"; @@ -12,7 +11,6 @@ import { useQuery, useQueryClient } from "@tanstack/react-query"; import axios from "axios"; import { AIRDCPP_SERVICE_BASE_URI } from "../../constants/endpoints"; - interface IAcquisitionPanelProps { query: any; comicObjectId: any; @@ -35,7 +33,7 @@ export const AcquisitionPanel = ( priority: PriorityEnum; } interface SearchResult { - id: string; + id: string; // Add other properties as needed slots: any; type: any; @@ -112,26 +110,20 @@ export const AcquisitionPanel = ( */ const search = async (searchData: any) => { setAirDCPPSearchResults([]); - socketIOInstance.emit( - "call", - "socket.search", - { - query: searchData, - config: { - protocol: `ws`, - hostname: `localhost:5600`, - username: `user`, - password: `pass`, - }, + socketIOInstance.emit("call", "socket.search", { + query: searchData, + config: { + protocol: `ws`, + hostname: `localhost:5600`, + username: `user`, + password: `pass`, }, - ); + }); }; socketIOInstance.on("searchResultAdded", ({ result }: any) => { setAirDCPPSearchResults((previousState) => { - const exists = previousState.some( - (item) => result.id === item.id, - ); + const exists = previousState.some((item) => result.id === item.id); if (!exists) { return [...previousState, result]; } @@ -205,7 +197,7 @@ export const AcquisitionPanel = ( search(manualQuery); }; - + return ( <>
@@ -334,118 +326,121 @@ export const AcquisitionPanel = ( - {map(airDCPPSearchResults, ({ dupe, type, name, id, slots, users, size }, idx) => { - return ( - - -

- {type.id === "directory" ? ( - - ) : null} - {ellipsize(name, 70)} -

- -
-
-
- {!isNil(dupe) ? ( + {map( + airDCPPSearchResults, + ({ dupe, type, name, id, slots, users, size }, idx) => { + return ( + + +

+ {type.id === "directory" ? ( + + ) : null} + {ellipsize(name, 70)} +

+ +
+
+
+ {!isNil(dupe) ? ( + + + + + + + Dupe + + + ) : null} + + {/* Nicks */} - + - + - Dupe + {users.user.nicks} - ) : null} - - {/* Nicks */} - - - - - - - {users.user.nicks} - - - {/* Flags */} - {users.user.flags.map((flag, idx) => ( - - - + {/* Flags */} + {users.user.flags.map((flag, idx) => ( + + + + + + + {flag} + - - - {flag} - - - ))} -
-
-
- - - {/* Extension */} - - - + ))} +
+
+
+ + + {/* Extension */} + + + + + + + {type.str} + - - - {type.str} + + + {/* Slots */} + + + + + + + {slots.total} slots; {slots.free} free + - - - - {/* Slots */} - - - - - - - {slots.total} slots; {slots.free} free - - - - - - - - ); - })} + + + + + + ); + }, + )}
diff --git a/src/client/components/shared/Carda.tsx b/src/client/components/shared/Carda.tsx index 1e21891..f6a1390 100644 --- a/src/client/components/shared/Carda.tsx +++ b/src/client/components/shared/Carda.tsx @@ -83,7 +83,7 @@ const renderCard = (props: ICardProps): ReactElement => { case "vertical-2": return ( -
+