🐞 Fixed a bug with search_results_updated listener for AirDC++
This commit is contained in:
@@ -6,7 +6,8 @@ import {
|
||||
SearchResponse,
|
||||
} from "threetwo-ui-typings";
|
||||
import {
|
||||
AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
AIRDCPP_SEARCH_RESULTS_ADDED,
|
||||
AIRDCPP_SEARCH_RESULTS_UPDATED,
|
||||
AIRDCPP_HUB_SEARCHES_SENT,
|
||||
AIRDCPP_RESULT_DOWNLOAD_INITIATED,
|
||||
AIRDCPP_DOWNLOAD_PROGRESS_TICK,
|
||||
@@ -46,7 +47,7 @@ export const search = (data: SearchData) => async (dispatch) => {
|
||||
// (it's probably a good idea to have some kind of throttling for the UI updates as there can be thousands of results)
|
||||
|
||||
dispatch({
|
||||
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
type: AIRDCPP_SEARCH_RESULTS_ADDED,
|
||||
groupedResult,
|
||||
});
|
||||
},
|
||||
@@ -60,7 +61,7 @@ export const search = (data: SearchData) => async (dispatch) => {
|
||||
async (groupedResult) => {
|
||||
// ...update properties of the existing result in the UI
|
||||
dispatch({
|
||||
type: AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
type: AIRDCPP_SEARCH_RESULTS_UPDATED,
|
||||
groupedResult,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -38,9 +38,10 @@ export const IMS_COMIC_BOOK_GROUPS_CALL_IN_PROGRESS =
|
||||
export const IMS_COMIC_BOOK_GROUPS_CALL_FAILED =
|
||||
"IMS_COMIC_BOOK_GROUPS_CALL_FAILED";
|
||||
|
||||
// AirDC++
|
||||
export const AIRDCPP_SEARCH_IN_PROGRESS = "AIRDCPP_SEARCH_IN_PROGRESS";
|
||||
export const AIRDCPP_SEARCH_RESULTS_RECEIVED =
|
||||
"AIRDCPP_SEARCH_RESULTS_RECEIVED";
|
||||
export const AIRDCPP_SEARCH_RESULTS_ADDED = "AIRDCPP_SEARCH_RESULTS_ADDED";
|
||||
export const AIRDCPP_SEARCH_RESULTS_UPDATED = "AIRDCPP_SEARCH_RESULTS_UPDATED";
|
||||
export const AIRDCPP_SEARCH_COMPLETE = "AIRDCPP_SEARCH_COMPLETE";
|
||||
|
||||
export const AIRDCPP_HUB_SEARCHES_SENT = "AIRDCPP_HUB_SEARCHES_SENT";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
AIRDCPP_SEARCH_IN_PROGRESS,
|
||||
AIRDCPP_SEARCH_RESULTS_RECEIVED,
|
||||
AIRDCPP_SEARCH_RESULTS_ADDED,
|
||||
AIRDCPP_SEARCH_RESULTS_UPDATED,
|
||||
AIRDCPP_HUB_SEARCHES_SENT,
|
||||
AIRDCPP_RESULT_DOWNLOAD_INITIATED,
|
||||
AIRDCPP_DOWNLOAD_PROGRESS_TICK,
|
||||
@@ -20,12 +21,23 @@ const initialState = {
|
||||
|
||||
function airdcppReducer(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case AIRDCPP_SEARCH_RESULTS_RECEIVED:
|
||||
case AIRDCPP_SEARCH_RESULTS_ADDED:
|
||||
return {
|
||||
...state,
|
||||
searchResults: [...state.searchResults, action.groupedResult],
|
||||
isAirDCPPSearchInProgress: true,
|
||||
};
|
||||
case AIRDCPP_SEARCH_RESULTS_UPDATED:
|
||||
const bundleToUpdateIndex = state.searchResults.findIndex(
|
||||
(bundle) => bundle.id === action.groupedResult.result.id,
|
||||
);
|
||||
const updatedState = [...state.searchResults];
|
||||
updatedState[bundleToUpdateIndex] = action.groupedResult;
|
||||
|
||||
return {
|
||||
...state,
|
||||
searchResults: updatedState,
|
||||
};
|
||||
case AIRDCPP_SEARCH_IN_PROGRESS:
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -16,6 +16,6 @@ export const detectTradePaperbacks = (deck): any => {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
console.log(compact(matches));
|
||||
// console.log(compact(matches));
|
||||
return compact(matches);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user