🔧 Fixing broken AirDCPP search

This commit is contained in:
2024-09-26 21:32:28 -04:00
parent 628e1f72e2
commit fe6100bb79
2 changed files with 148 additions and 151 deletions

View File

@@ -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 = `<div className="overflow-x-auto w-fit mt-4 rounded-lg border border-gray-200 dark:border-gray-500">
// <table className="min-w-full divide-y-2 divide-gray-200 dark:divide-gray-500 text-md">
// <thead>
// <tr>
// <th className="whitespace-nowrap px-2 py-2 font-medium text-gray-900 dark:text-slate-200">
// Name
// </th>
// <th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
// Type
// </th>
// <th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
// Slots
// </th>
// <th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
// Actions
// </th>
// </tr>
// </thead>
// <tbody className="divide-y divide-slate-100 dark:divide-gray-500">
// {map(airDCPPSearchResults, ({ result, search_id }, idx) => {
// return (
// <tr
// key={idx}
// className={
// !isNil(result.dupe)
// ? "bg-gray-100 dark:bg-gray-700"
// : "w-fit text-sm"
// }
// >
// <td className="whitespace-nowrap px-3 py-3 text-gray-700 dark:text-slate-300">
// <p className="mb-2">
// {result.type.id === "directory" ? (
// <i className="fas fa-folder"></i>
// ) : null}
// {ellipsize(result.name, 70)}
// </p>
//
// <dl>
// <dd>
// <div className="inline-flex flex-row gap-2">
// {!isNil(result.dupe) ? (
// <span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
// <span className="pr-1 pt-1">
// <i className="icon-[solar--copy-bold-duotone] w-5 h-5"></i>
// </span>
//
// <span className="text-md text-slate-500 dark:text-slate-900">
// Dupe
// </span>
// </span>
// ) : null}
//
// {/* Nicks */}
// <span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
// <span className="pr-1 pt-1">
// <i className="icon-[solar--user-rounded-bold-duotone] w-5 h-5"></i>
// </span>
//
// <span className="text-md text-slate-500 dark:text-slate-900">
// {result.users.user.nicks}
// </span>
// </span>
// {/* Flags */}
// {result.users.user.flags.map((flag, idx) => (
// <span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
// <span className="pr-1 pt-1">
// <i className="icon-[solar--tag-horizontal-bold-duotone] w-5 h-5"></i>
// </span>
//
// <span className="text-md text-slate-500 dark:text-slate-900">
// {flag}
// </span>
// </span>
// ))}
// </div>
// </dd>
// </dl>
// </td>
// <td>
// {/* Extension */}
// <span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
// <span className="pr-1 pt-1">
// <i className="icon-[solar--zip-file-bold-duotone] w-5 h-5"></i>
// </span>
//
// <span className="text-md text-slate-500 dark:text-slate-900">
// {result.type.str}
// </span>
// </span>
// </td>
// <td className="px-2">
// {/* Slots */}
// <span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
// <span className="pr-1 pt-1">
// <i className="icon-[solar--settings-minimalistic-bold-duotone] w-5 h-5"></i>
// </span>
//
// <span className="text-md text-slate-500 dark:text-slate-900">
// {result.slots.total} slots; {result.slots.free} free
// </span>
// </span>
// </td>
// <td className="px-2">
// <button
// className="flex space-x-1 sm:mt-0 sm:flex-row sm:items-center rounded-lg border border-green-400 dark:border-green-200 bg-green-200 px-3 py-1 text-gray-500 hover:bg-transparent hover:text-green-600 focus:outline-none focus:ring active:text-indigo-500"
// onClick={() =>
// download(
// airDCPPSearchInstance.id,
// result.id,
// comicObjectId,
// result.name,
// result.size,
// result.type,
// {
// protocol: `ws`,
// hostname: `localhost:5600`,
// username: `user`,
// password: `pass`,
// },
// )
// }
// >
// <span className="text-xs">Download</span>
// <span className="w-5 h-5">
// <i className="h-5 w-5 icon-[solar--download-bold-duotone]"></i>
// </span>
// </button>
// </td>
// </tr>
// );
// })}
// </tbody>
// </table>
// </div>`;
return (
<>
<div className="mt-5">
@@ -313,142 +443,9 @@ export const AcquisitionPanel = (
)}
{/* AirDC++ results */}
<div className="columns">
<div className="">
{!isNil(airDCPPSearchResults) && !isEmpty(airDCPPSearchResults) ? (
<div className="overflow-x-auto w-fit mt-4 rounded-lg border border-gray-200 dark:border-gray-500">
<table className="min-w-full divide-y-2 divide-gray-200 dark:divide-gray-500 text-md">
<thead>
<tr>
<th className="whitespace-nowrap px-2 py-2 font-medium text-gray-900 dark:text-slate-200">
Name
</th>
<th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
Type
</th>
<th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
Slots
</th>
<th className="whitespace-nowrap py-2 font-medium text-gray-900 dark:text-slate-200">
Actions
</th>
</tr>
</thead>
<tbody className="divide-y divide-slate-100 dark:divide-gray-500">
{map(airDCPPSearchResults, ({ result, search_id }, idx) => {
return (
<tr
key={idx}
className={
!isNil(result.dupe)
? "bg-gray-100 dark:bg-gray-700"
: "w-fit text-sm"
}
>
<td className="whitespace-nowrap px-3 py-3 text-gray-700 dark:text-slate-300">
<p className="mb-2">
{result.type.id === "directory" ? (
<i className="fas fa-folder"></i>
) : null}
{ellipsize(result.name, 70)}
</p>
<dl>
<dd>
<div className="inline-flex flex-row gap-2">
{!isNil(result.dupe) ? (
<span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
<span className="pr-1 pt-1">
<i className="icon-[solar--copy-bold-duotone] w-5 h-5"></i>
</span>
<span className="text-md text-slate-500 dark:text-slate-900">
Dupe
</span>
</span>
) : null}
{/* Nicks */}
<span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
<span className="pr-1 pt-1">
<i className="icon-[solar--user-rounded-bold-duotone] w-5 h-5"></i>
</span>
<span className="text-md text-slate-500 dark:text-slate-900">
{result.users.user.nicks}
</span>
</span>
{/* Flags */}
{result.users.user.flags.map((flag, idx) => (
<span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
<span className="pr-1 pt-1">
<i className="icon-[solar--tag-horizontal-bold-duotone] w-5 h-5"></i>
</span>
<span className="text-md text-slate-500 dark:text-slate-900">
{flag}
</span>
</span>
))}
</div>
</dd>
</dl>
</td>
<td>
{/* Extension */}
<span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
<span className="pr-1 pt-1">
<i className="icon-[solar--zip-file-bold-duotone] w-5 h-5"></i>
</span>
<span className="text-md text-slate-500 dark:text-slate-900">
{result.type.str}
</span>
</span>
</td>
<td className="px-2">
{/* Slots */}
<span className="inline-flex items-center bg-slate-50 text-slate-800 text-xs font-medium px-2 rounded-md dark:text-slate-900 dark:bg-slate-400">
<span className="pr-1 pt-1">
<i className="icon-[solar--settings-minimalistic-bold-duotone] w-5 h-5"></i>
</span>
<span className="text-md text-slate-500 dark:text-slate-900">
{result.slots.total} slots; {result.slots.free} free
</span>
</span>
</td>
<td className="px-2">
<button
className="flex space-x-1 sm:mt-0 sm:flex-row sm:items-center rounded-lg border border-green-400 dark:border-green-200 bg-green-200 px-3 py-1 text-gray-500 hover:bg-transparent hover:text-green-600 focus:outline-none focus:ring active:text-indigo-500"
onClick={() =>
download(
airDCPPSearchInstance.id,
result.id,
comicObjectId,
result.name,
result.size,
result.type,
{
protocol: `ws`,
hostname: `localhost:5600`,
username: `user`,
password: `pass`,
},
)
}
>
<span className="text-xs">Download</span>
<span className="w-5 h-5">
<i className="h-5 w-5 icon-[solar--download-bold-duotone]"></i>
</span>
</button>
</td>
</tr>
);
})}
</tbody>
</table>
</div>
<></>
) : (
<div className="">
<article

View File

@@ -45,8 +45,8 @@ export const determineCoverFile = (data): any => {
// 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)) {