Skip to content

Commit

Permalink
Merge pull request #522 from samvera-labs/searching_fixes
Browse files Browse the repository at this point in the history
Handle case when some transcripts have hits but others do not
  • Loading branch information
cjcolvar authored Jun 17, 2024
2 parents 836f27f + be4d642 commit 027beff
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/services/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,9 @@ export const useSearchCounts = ({ searchResults, canvasTranscripts }) => {
}

const hitCounts = searchResults.counts;

let canvasTranscriptsWithCount = [];
canvasTranscripts.map((ct) => {
const numberOfHits = hitCounts.find((h) => h.transcriptURL === ct.url).numberOfHits;
const numberOfHits = hitCounts.find((h) => h.transcriptURL === ct.url)?.numberOfHits || 0;
canvasTranscriptsWithCount.push({ ...ct, numberOfHits });
});

Expand Down

0 comments on commit 027beff

Please sign in to comment.