From 8fdd8d022632970837616368e757c90728cb34d2 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Mon, 7 Feb 2022 09:55:21 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=A2=20Wired=20up=20the=20updated=20Ela?= =?UTF-8?q?sticsearch=20call=20to=20the=20potential=20matches=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/client/reducers/comicinfo.reducer.js | 27 +++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f17d8df..95ee46a 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "ellipsize": "^0.1.0", "express": "^4.17.1", "fastest-validator": "^1.11.0", - "filename-parser": "^1.0.1", + "filename-parser": "^1.0.2", "final-form": "^4.20.2", "final-form-arrays": "^3.0.2", "html-to-text": "^8.1.0", diff --git a/src/client/reducers/comicinfo.reducer.js b/src/client/reducers/comicinfo.reducer.js index 92c3b6a..9cd02de 100644 --- a/src/client/reducers/comicinfo.reducer.js +++ b/src/client/reducers/comicinfo.reducer.js @@ -1,4 +1,4 @@ -import { isEmpty, extend, each } from "lodash"; +import { isEmpty, extend, each, matches } from "lodash"; import { CV_API_CALL_IN_PROGRESS, CV_SEARCH_SUCCESS, @@ -71,19 +71,30 @@ function comicinfoReducer(state = initialState, action) { }; case CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS: - // console.log("jagan", action); return { ...state, issuesForVolume: action.issues, inProgress: false, }; - case CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED: - console.log(action); - const updatedState = [...state.issuesForVolume]; - // updatedState[issueToUpdateIndex].matches = action.result.matches; - // console.log(issueToUpdateIndex); - // console.log(updatedState[issueToUpdateIndex]); + case CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED: + const updatedState = [...state.issuesForVolume]; + const matches = action.matches.filter( + (match) => !isEmpty(match.hits.hits), + ); + matches.forEach((match) => { + state.issuesForVolume.forEach((issue, idx) => { + issue.matches = []; + match.hits.hits.forEach((hit) => { + if ( + parseInt(issue.issue_number, 10) === + hit._source.inferredMetadata.issue.number + ) { + issue.matches.push(hit); + } + }); + }); + }); return { ...state,