From fe6100bb796490a18dbbc8697f550abdfed7a1c3 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Thu, 26 Sep 2024 21:32:28 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixing=20broken=20AirDCPP=20sear?= =?UTF-8?q?ch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComicDetail/AcquisitionPanel.tsx | 295 +++++++++--------- src/client/shared/utils/metadata.utils.ts | 4 +- 2 files changed, 148 insertions(+), 151 deletions(-) diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index e27e753..8687a03 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -35,10 +35,7 @@ export const AcquisitionPanel = ( priority: PriorityEnum; } interface SearchResult { - result: { id: number; - }; - search_id: number; // Add other properties as needed } @@ -46,7 +43,6 @@ export const AcquisitionPanel = ( // Use the already connected socket instance to emit events socketIOInstance.emit("initiateSearch", searchQuery); }; - const { data: settings, isLoading, @@ -122,31 +118,31 @@ export const AcquisitionPanel = ( password: `pass`, }, }, - (data: any) => console.log(data), ); }; - socketIOInstance.on("searchResultAdded", ({ groupedResult }: any) => { + socketIOInstance.on("searchResultAdded", ({ result }: any) => { + console.log("yelaweda", result); setAirDCPPSearchResults((previousState) => { const exists = previousState.some( - (item) => groupedResult.result.id === item.result.id, + (item) => result.id === item.id, ); if (!exists) { - return [...previousState, groupedResult]; + return [...previousState, result]; } return previousState; }); }); - socketIOInstance.on("searchResultUpdated", ({ updatedResult }: any) => { - console.log("endh"); + socketIOInstance.on("searchResultUpdated", ({ result }: any) => { + console.log("endh", result); // ...update properties of the existing result in the UI const bundleToUpdateIndex = airDCPPSearchResults?.findIndex( - (bundle) => bundle.result.id === updatedResult.result.id, + (bundle) => bundle.id === result.id, ); const updatedState = [...airDCPPSearchResults]; - if (!isNil(difference(updatedState[bundleToUpdateIndex], updatedResult))) { - updatedState[bundleToUpdateIndex] = updatedResult; + if (!isNil(difference(updatedState[bundleToUpdateIndex], result))) { + updatedState[bundleToUpdateIndex] = result; } setAirDCPPSearchResults((state) => [...state, ...updatedState]); }); @@ -205,7 +201,141 @@ export const AcquisitionPanel = ( search(manualQuery); }; - + console.log(airDCPPSearchResults); + // const comment = `
+ // + // + // + // + // + // + // + // + // + // + // {map(airDCPPSearchResults, ({ result, search_id }, idx) => { + // return ( + // + // + // + // + // + // + // ); + // })} + // + //
+ // Name + // + // Type + // + // Slots + // + // Actions + //
+ //

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

+ // + //
+ //
+ //
+ // {!isNil(result.dupe) ? ( + // + // + // + // + // + // + // Dupe + // + // + // ) : null} + // + // {/* Nicks */} + // + // + // + // + // + // + // {result.users.user.nicks} + // + // + // {/* Flags */} + // {result.users.user.flags.map((flag, idx) => ( + // + // + // + // + // + // + // {flag} + // + // + // ))} + //
+ //
+ //
+ //
+ // {/* Extension */} + // + // + // + // + // + // + // {result.type.str} + // + // + // + // {/* Slots */} + // + // + // + // + // + // + // {result.slots.total} slots; {result.slots.free} free + // + // + // + // + //
+ //
`; return ( <>
@@ -313,142 +443,9 @@ export const AcquisitionPanel = ( )} {/* AirDC++ results */} -
+
{!isNil(airDCPPSearchResults) && !isEmpty(airDCPPSearchResults) ? ( -
- - - - - - - - - - - {map(airDCPPSearchResults, ({ result, search_id }, idx) => { - return ( - - - - - - - ); - })} - -
- Name - - Type - - Slots - - Actions -
-

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

- -
-
-
- {!isNil(result.dupe) ? ( - - - - - - - Dupe - - - ) : null} - - {/* Nicks */} - - - - - - - {result.users.user.nicks} - - - {/* Flags */} - {result.users.user.flags.map((flag, idx) => ( - - - - - - - {flag} - - - ))} -
-
-
-
- {/* Extension */} - - - - - - - {result.type.str} - - - - {/* Slots */} - - - - - - - {result.slots.total} slots; {result.slots.free} free - - - - -
-
+ <> ) : (
{ // comicvine if (!isEmpty(data.comicvine)) { coverFile.comicvine.url = data?.comicvine?.image.small_url; - coverFile.comicvine.issueName = data.comicvine.name; - coverFile.comicvine.publisher = data.comicvine.publisher.name; + coverFile.comicvine.issueName = data.comicvine?.name; + coverFile.comicvine.publisher = data.comicvine?.publisher?.name; } // rawFileDetails if (!isEmpty(data.rawFileDetails)) {