🔧 Refactoring
This commit is contained in:
@@ -33,34 +33,6 @@ export const search = (data: SearchData) => async (dispatch) => {
|
|||||||
}
|
}
|
||||||
const instance: SearchInstance = await SocketService.post("search");
|
const instance: SearchInstance = await SocketService.post("search");
|
||||||
|
|
||||||
// We want to get notified about every new result in order to make the user experience better
|
|
||||||
await SocketService.addListener(
|
|
||||||
`search/${instance.id}`,
|
|
||||||
"search_result_added",
|
|
||||||
(groupedResult) => {
|
|
||||||
dispatch({
|
|
||||||
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
|
||||||
groupedResult: groupedResult.result,
|
|
||||||
});
|
|
||||||
// ...add the received result in the UI
|
|
||||||
// (it's probably a good idea to have some kind of throttling for the UI updates as there can be thousands of results)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// We also want to update the existing items in our list when new hits arrive for the previously listed files/directories
|
|
||||||
await SocketService.addListener(
|
|
||||||
`search/${instance.id}`,
|
|
||||||
"search_result_updated",
|
|
||||||
async (groupedResult) => {
|
|
||||||
console.log(groupedResult);
|
|
||||||
dispatch({
|
|
||||||
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
|
||||||
results: groupedResult,
|
|
||||||
});
|
|
||||||
// ...update properties of the existing result in the UI
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await SocketService.addListener(
|
await SocketService.addListener(
|
||||||
`search/${instance.id}`,
|
`search/${instance.id}`,
|
||||||
"search_hub_searches_sent",
|
"search_hub_searches_sent",
|
||||||
@@ -90,15 +62,15 @@ export const search = (data: SearchData) => async (dispatch) => {
|
|||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
|
||||||
// await sleep(10000);
|
await sleep(10000);
|
||||||
// const results = await SocketService.get(
|
const results = await SocketService.get(
|
||||||
// `search/${instance.id}/results/0/25`,
|
`search/${instance.id}/results/0/125`,
|
||||||
// );
|
);
|
||||||
|
|
||||||
// dispatch({
|
dispatch({
|
||||||
// type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||||
// results,
|
results,
|
||||||
// });
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("ERO", error);
|
console.log("ERO", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ 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;
|
||||||
const airDCPPSearchResults = useSelector(
|
const airDCPPSearchResults = useSelector((state: RootState) => {
|
||||||
(state: RootState) => { console.log(state); return state.airdcpp.results;}
|
return state.airdcpp.searchResults;
|
||||||
);
|
});
|
||||||
const isAirDCPPSearchInProgress = useSelector(
|
const isAirDCPPSearchInProgress = useSelector(
|
||||||
(state: RootState) => state.airdcpp.isAirDCPPSearchInProgress,
|
(state: RootState) => state.airdcpp.isAirDCPPSearchInProgress,
|
||||||
);
|
);
|
||||||
@@ -104,8 +104,7 @@ export const AcquisitionPanel = (
|
|||||||
</div>
|
</div>
|
||||||
{/* AirDC++ results */}
|
{/* AirDC++ results */}
|
||||||
<div>
|
<div>
|
||||||
ASDASD {JSON.stringify(airDCPPSearchResults)}
|
{!isNil(airDCPPSearchResults) && (
|
||||||
{/* {!isNil(airDCPPSearchResults) && (
|
|
||||||
<table className="table is-striped">
|
<table className="table is-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -172,7 +171,7 @@ export const AcquisitionPanel = (
|
|||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)} */}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,22 +9,21 @@ import {
|
|||||||
import { LOCATION_CHANGE } from "connected-react-router";
|
import { LOCATION_CHANGE } from "connected-react-router";
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
|
searchResults: [],
|
||||||
isAirDCPPSearchInProgress: false,
|
isAirDCPPSearchInProgress: false,
|
||||||
searchInfo: null,
|
searchInfo: null,
|
||||||
searchInstance: null,
|
searchInstance: null,
|
||||||
downloadResult: null,
|
downloadResult: null,
|
||||||
bundleDBImportResult: null,
|
bundleDBImportResult: null,
|
||||||
searchResults: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function airdcppReducer(state = initialState, action) {
|
function airdcppReducer(state = initialState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case AIRDCPP_SEARCH_RESULTS_RECEIVED:
|
case AIRDCPP_SEARCH_RESULTS_RECEIVED:
|
||||||
console.log("mad", state.searchResults);
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isAirDCPPSearchInProgress: true,
|
searchResults: action.results,
|
||||||
searchResults: [...state.searchResults, action.groupedResult],
|
isAirDCPPSearchInProgress: false,
|
||||||
};
|
};
|
||||||
case AIRDCPP_SEARCH_IN_PROGRESS:
|
case AIRDCPP_SEARCH_IN_PROGRESS:
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user