Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Improve automatic recipe matching
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXyfir committed Sep 17, 2019
1 parent dbff702 commit 6f7cdb1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions components/reader/ReaderControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,19 @@ export function ReaderControls({
},
[] as typeof matches
)
.sort((a, b) => a.score - b.score);
.sort((a, b) => a.score - b.score)
.filter((match, i, arr) => {
// Remove if 0.5 or over
if (match.score >= 0.5) return false;

// Choose recipe with highest score that passes threshold
if (match && match.score <= 0.5) {
// Remove if other have same score
if (arr.filter(m => m.score == match.score).length > 1) return false;

return true;
});

// Choose recipe with lowest (best) score that passes threshold
if (match && match.score < 0.5) {
const recipe = await downloadRecipe(match.item.id, pub!.id);
dispatch({ recipe });
enqueueSnackbar(`"${getRecipeName(recipe.id)}" recipe loaded`);
Expand Down

0 comments on commit 6f7cdb1

Please sign in to comment.